I tried to make the SOAP call according to the Simplest SOAP example
I am able to send the request through this code but there is no response coming from the server. The sample code i given below:
enter code here
<html>
<head>
<title>SOAP call sample</title>
<script language="Javascript">
<!--
function xmlhttpPost() {
var symbol = "MSFT";
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("POST", "http://www.webservicex.net/stockquote.asmx?op=GetQuote",true);
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState == 4) {
alert("ready state callback:"+xmlhttp.readyState);
alert("response text or XML"xmlhttp.responseText);
var json = XMLObjectifier.xmlToJSON(xmlhttp.responseXML);
var result = json.Body[0].GetQuoteResponse[0].GetQuoteResult[0].Text;
json = XMLObjectifier.xmlToJSON(XMLObjectifier.textToXML(result));
alert(symbol + ' Stock Quote: $' + json.Stock[0].Last[0].Text);
}
}
xmlhttp.setRequestHeader("SOAPAction", "http://www.webserviceX.NET/GetQuote");
xmlhttp.setRequestHeader("Content-Type", "text/xml");
xmlhttp.setRequestHeader("POST","/stockquote.asmx HTTP/1.1");
xmlhttp.setRequestHeader("Host","www.webservicex.net");
xmlhttp.setRequestHeader("Content-Length",1000);
alert("setrequest header completed");
var xml = '<?xml version="1.0" encoding="utf-8"?>' +
'<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> ' +
'<GetQuote xmlns="http://www.webserviceX.NET/"> ' +
'<symbol>' + symbol + '</symbol> ' +
'</GetQuote> ' +
'</soap:Body> ' +
'</soap:Envelope>';
xmlhttp.send(xml);
alert("request sent"+xmlhttp);
}
//-->
</script>
</head>
<form name="main">
<table>
<tr>
<td> <input value="Submit to eBay => " type="button"
onclick='JavaScript:xmlhttpPost()'></td>
<td><textarea name="eBayXMLResponse" wrap="soft" rows="40" cols="50" style="overflow:scroll" ID="Textarea1"></textarea></td>
</tr>
</table>
</form>
</html>
I tried this sample with dynamic web project through eclipse and running through apache-tomcat-7.0.25 app server.Is this enough to run this sample? Please help me to display the response in the browser console. i am struggling for a week in this issue..... please let me know if anybody has idea about this.