我有描述如下web服務方法:與Windows Phone 7和添加SOAP頭消費的WebServices
POST /servis.asmx HTTP/1.1
Host: webservice.myproject.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/MyMethod"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<AuthHeader xmlns="http://tempuri.org/">
<Username>string</Username>
<Password>string</Password>
</AuthHeader>
</soap:Header>
<soap:Body>
<MyMethod xmlns="http://tempuri.org/" />
</soap:Body>
</soap:Envelope>
我試圖開發一種消耗此WebService方法在Windows Phone 7應用程序。在Visual Studio中,我將服務參考添加到了我的項目中。我在.net平臺上創建了Webservice客戶端對象,並創建了AuthHeader對象並設置其用戶名和密碼。下面的代碼是不是我的代碼,但它像礦山:
AuthWebService.WebService webService = new AuthWebService.WebService();
AuthWebService.AuthHeader authentication = new AuthWebService.AuthHeader();
authentication.Username = "test";
authentication.Password = "test";
webService.AuthHeaderValue = authentication;
但是,當我試圖設置服務與頭使用此代碼行:
webService.AuthHeaderValue = authentication;
這是行不通的。 webservice對象沒有AuthHeaderValue屬性。我嘗試過在桌面應用程序或Web應用程序中運行,但在Windows Phone 7應用程序中沒有。
有沒有人有關於這個問題的建議?現在感謝。