Hi All
When I call a Java-Based webservice with username+password authentication, I need to add custom SoapHeader class which is like this:
[System.Xml.Serialization.XmlTypeAttribute(Namespace="XXX")]
[System.Xml.Serialization.XmlRootAttribute("Security", Namespace="XXX",IsNullable = false)]
public class CustomSoapHeader : SoapHeader{
public string username;
public string password;
}
And I add customeSoapHeader property to the Proxy class also rewrite the proxy constructor method like this:
public CustomeSoapHeader cheader;
public XXXSvc(string username, string password){
this.url = "~~~~~~~~~~~~~~";
this.cheader = new CustomeSoapHeader(){username = username, password = password};
}
Then I add tag for each method
[System.Web.Services.Protocols.SoapHeaderAttribute("cheader")]
public int myWebMethod(param1, param2){
}
After these steps above I can successfully call the method.
But now I need to call these web methods via a Windows Phone client. How could I pass the authentication??
I add service reference to Windows Phone App then it automatically generate the proxy reference.cs and ServiceReferences.ClientConfig
in the config file it uses basicHttpBinding, and I change the security mode to "TransportWithMessageCredential" like this:
<bindings>
<basicHttpBinding>
<binding name="myoWSSoapBinding" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="TransportWithMessageCredential" />
</binding>
</basicHttpBinding>
</bindings>
Then I use ClientCredentials to pass through the authentication like this:
proxy.ClientCredentials.username.username = "myUserName"
proxy.ClientCredentials.username.password = "myPassword"
But can not call the method successfully.
How can I solve this problem??
Many Appreciate and thanks for your kindly help, waiting for your answers ^_^