I have a webservice method which described as follow:
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>
And i’m trying develop a Windows Phone 7 application which consumes this webservice method. In Visual Studio, i added the service referance to my project. I created Webservice client object like as doing it in .net platform, and created AuthHeader object and set its username and password. The following code is not my code but it like as mine:
AuthWebService.WebService webService = new AuthWebService.WebService();
AuthWebService.AuthHeader authentication = new AuthWebService.AuthHeader();
authentication.Username = "test";
authentication.Password = "test";
webService.AuthHeaderValue = authentication;
But when i trying to set services headers with using this code line:
webService.AuthHeaderValue = authentication;
it doesn’t work. webservice object doesn’t have AuthHeaderValue property. I tried it in desktop application or a web application it works but in Windows Phone 7 application it did not.
Does anybody have a suggestion about this issue? Thanks for now.
This is my friend’s solution for this problem and it is work for me:
And the full blog post is here: WP7 SOAP Web Service with Custom Headers