Reputation: 2088
i have a secured web service which issues a token if authentication is successful and everything works fine on a c#.net page. the issue i am having is i want to access the service calls from jQuery.
How can i access / modify / or even add a SOAP header in jQuery call. my custom SOAP header class header is as follows:
public class SecuredWebServiceHeader : System.Web.Services.Protocols.SoapHeader
{
public string Username;
public string Password;
public string AuthenticatedToken;
}
i tired beforeSend in $.ajax like
beforeSend: function (xhr) {
xhr.setRequestHeader('Authorization', '<%=GetToken()%>');
},
but the web service does not see the header all.
any ideas on how to solve this?
Upvotes: 1
Views: 1605
Reputation: 1714
$.ajax({
type: 'POST',
url: servicename + "/" + functionName,
contentType: 'text/xml; charset=utf-8',
headers: {
SOAPAction: 'Your service'
},
data: 'Your full SoapHeader Here',
success: successFn,
error: errorFn
});
For details go through Jeferry To's Reply
Get additional help below:
Upvotes: 2