我有描述如下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应用程序中没有。
有没有人有关于这个问题的建议?现在感谢。