Note that there are some explanatory texts on larger screens.

plurals
  1. POSOAP request JavaScript in Browser not giving response
    primarykey
    data
    text
    <p>I am trying to access SOAP service hosted in the server using my Chrome browser in window 7 . I have tested the same service and soap action in SOAPUI and getting response and also in android using icesoap and getting the right response from the server ,Now I am wishing to get the response in browser with the following code written in java script to do the same , so that i can implement further , and it is giving me undefined error with ie xmlHttp.status == 0</p> <p>The following code I used and saved as HTML file in window desktop( <strong><em>c:/Users/vipin.sahu.OM/Desktop/New folder/soap.html</em></strong>) and run it into browser </p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;SOAP JavaScript Client Test&lt;/title&gt; &lt;script type="text/javascript"&gt; function soap() { var xmlhttp = new XMLHttpRequest(); xmlhttp.open("POST", "http://65.17.222.114/t2green/servicecontract/Courses.svc?wsdl", true); xmlhttp.setRequestHeader("SOAPAction", "http://tempuri.org/ICourses/GetCountries"); // build SOAP request var sr ='&lt;?xml version="1.0" encoding="utf-8"?&gt;' + '&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/"&gt;'+ '&lt;soapenv:Header/&gt;'+ '&lt;soapenv:Body&gt;'+ '&lt;tem:GetCountries&gt;'+ '&lt;/tem:GetCountries&gt;'+ '&lt;/soapenv:Body&gt;'+ '&lt;/soapenv:Envelope&gt;'; xmlhttp.onerror = function(e) { alert("Error ocurred. Error = " + e.message); } xmlhttp.ontimeout = function(e) { alert("Timeout error!"); } xmlhttp.onreadystatechange = function () { if (xmlhttp.readyState == 4) { if (xmlHttp.status == 200 || xmlHttp.status == 0) { alert(xmlhttp.status); } else{ alert(xmlhttp.status); } } else{ alert('error in response'); } } xmlhttp.setRequestHeader("Content-Length", sr.length); xmlhttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8"); xmlhttp.send(sr); } &lt;/script&gt; &lt;script type="text/javascript"&gt; function test(){ alert('ok alert is still working'); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form name="Demo" action="" method="post"&gt; &lt;div&gt; &lt;input type="button" value="Click Me" onclick="test()" /&gt; &lt;input type="button" value="Soap" onclick="soap()" /&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;html&gt; Here are following url and action I used in android and getting requisite response </code></pre> <p><strong>URL</strong> "http://65.17.222.114/t2green/servicecontract/courses.svc"</p> <p><strong>Soap_action</strong> "http://tempuri.org/ICourses/GetCountries"</p> <p><strong>Request</strong> –</p> <pre><code> &lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/"&gt; &lt;soapenv:Header/&gt; &lt;soapenv:Body&gt; &lt;tem:GetCountries/&gt; &lt;/soapenv:Body&gt; &lt;/soapenv:Envelope&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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