My android mobile app communicates with web methods. They require user's authentication so I send username and password inside SOAP header as in this link. I've checked it and it generated correctly
<v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance"
xmlns:d="http://www.w3.org/2001/XMLSchema"
xmlns:c="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:v="http://schemas.xmlsoap.org/soap/envelope/">
<v:Header>
<n0:AuthHeader xmlns:n0="http://tempuri.org/">
<n0:user>x</n0:user>
<n0:pass>y</n0:pass>
</n0:AuthHeader>
</v:Header>
<v:Body>
<AuthenticationUser xmlns="http://tempuri.org/" id="o0" c:root="1" />
</v:Body>
</v:Envelope>
But on the server side, the web method AuthenticationUser()
receives an empty SOAP.
[WebMethod]
[SoapHeader("SoapHeader")]
public string AuthenticationUser()
{
if (SoapHeader == null)
return "Please provide Username and Password !" ;
if (string.IsNullOrEmpty(SoapHeader.userName) || string.IsNullOrEmpty(SoapHeader.password))
return "Please provide Username and Password !!" ;
//Check is User credentials Valid
if (!SoapHeader.IsUserCredentialsValid(SoapHeader.userName, SoapHeader.password))
return "Invalid Username or Password !!!";
// Create and store the AuthenticatedToken before returning it
string token = Guid.NewGuid().ToString();
HttpRuntime.Cache.Add(
token,
SoapHeader.userName,
null,
System.Web.Caching.Cache.NoAbsoluteExpiration,
TimeSpan.FromMinutes(30),
System.Web.Caching.CacheItemPriority.NotRemovable,
null
);
return token;
}
I get the response from AuthenticationUser()
web method in my app
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<AuthenticationUserResponse xmlns="http://tempuri.org/">
<AuthenticationUserResult>
Please provide Username and Password !
</AuthenticationUserResult>
</AuthenticationUserResponse>
</soap:Body>
</soap:Envelope>
I don't know why did AuthenticationUser()
web method receive empty SOAP?? Any help will be much appreciated.