Hi
Can any one please suggest the resources / sample code to make use of the webmethod present in webserivice
Thanks
Swarupa
Hi Swarupa,
Following is a simple running example. In practice, though you would be better off using some kind of a SOAP library.
CODEBOX
var symbol = "YHOO";
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("POST", "http://209.162.186.60//stockquote.asmx?op=GetQuote",true);
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState == 4) {
log(xmlhttp.responseText);
// do whatever with the data
}
}
xmlhttp.setRequestHeader("SOAPAction", "http://www.webserviceX.NET/GetQuote");
xmlhttp.setRequestHeader("Content-Type", "text/xml");
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);
Thanks,
Vivek