Note that there are some explanatory texts on larger screens.

plurals
  1. POSOAP Authentication via web service using jQuery
    text
    copied!<p>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:</p> <ol> <li><p><a href="http://dotnetslackers.com/articles/aspnet/Securing-ASP-Net-Web-Services-with-Forms-Authentication.aspx" rel="nofollow">Securing ASP.Net Web Service using SOAP</a></p></li> <li><p><a href="http://openlandscape.wordpress.com/2009/09/25/call-soap-xm-web-services-with-jquery-ajax/" rel="nofollow">Calling Webservice from Jquery (Posting SOAP Header)</a></p></li> </ol> <p>Code:</p> <pre><code>function logIn(username, password, token) { var soapMessage = '&lt;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/"&gt; \ &lt;soap:Body&gt; \ &lt;SecuredWebServiceHeader xmlns="http://tempuri.org/"&gt; \ &lt;Username&gt;' + username + '&lt;/Username&gt; \ &lt;Password&gt;' + password + '&lt;/Password&gt; \ &lt;AuthenticatedToken&gt;' + token + '&lt;/AuthenticatedToken&gt; \ &lt;/SecuredWebServiceHeader&gt; \ &lt;/soap:Body&gt; \ &lt;/soap:Envelope&gt;'; $.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) } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload