I have a Webservice that expects a soap header and return an authentication token. I have managed to post the soap header to the webservice using jquery. The problem is how do i make the browser to send the authenticated token on each request for authorization over the web service. Your help will be much appriciated. Helpful links i used are given below: Reference:
Code:
function logIn(username, password, token) {
var soapMessage =
'<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:Body> \
<SecuredWebServiceHeader xmlns="http://tempuri.org/"> \
<Username>' + username + '</Username> \
<Password>' + password + '</Password> \
<AuthenticatedToken>' + token + '</AuthenticatedToken> \
</SecuredWebServiceHeader> \
</soap:Body> \
</soap:Envelope>';
$.ajax({
url: "http://localhost/wstest/Service.asmx/AuthenticateUser",
type: "POST",
dataType: "xml",
data: soapMessage,
complete: endLogin,
contentType: "text/xml; charset=\"utf-8\""
});
return false;
}
function endLogin(xmlHttpRequest, status) {
alert(xmlHttpRequest.responseXML)
}