0
Posted on 4:32 AM by prajeesh and filed under ,
In a previous post i have explained about calling a web service from javascript, please see this post to see calling a web service without parameters.
Suppose you have a web service that accepts user name and password and returns a value in XML format and you want to show the returned value in a webpage or a widget.

For example :

<?xml version="1.0" encoding="utf-8" ?>
<int xmlns="http://tempuri.org/">1</int>

You can use following code snippet to call a web service from javascript:
<script language="text/javascript">
var returned_data;
var request = new XMLHttpRequest();
//function to initialize web service
function initializeWebservice()
{
var url="http://2test.hopto.org/Leadservice.asmx/GetLeadCounts?UserName=Prajeesh&Password=123456";; //Web service url
request.onreadystatechange = webStatusProc;
request.open( "GET", url, true );
request.send();
}
//function to process webservice response
function webStatusProc()
{
if (request.readyState == 4) // Request completed?
{
response = request.responseXML.toXML();
XML = XMLDOM.parse( response);
returned_data= XML.evaluate('string(/int)');
alert(returned-data);
//do anything with returned data
}
}
</script> Shout it kick it on DotNetKicks.com
0
Responses to ... Calling parameterized XML web service from javascript