Showing posts with label web service. Show all posts
Showing posts with label web service. Show all posts
0
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://Localhost/Testwebservice.asmx/GetLeadCounts; //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>
Posted on 2:46 PM by prajeesh and filed under
Javascript,
web service
Suppose you have a web service that 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://Localhost/Testwebservice.asmx/GetLeadCounts; //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>
0
tag
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>
Posted on 4:25 AM by prajeesh and filed under
ASP.net,
web service
If you find "The test form is only available for requests from the local machine" message in your webservice page after hosted in your server, dont worry just add following tags in your web.config file just before </system.web>tag
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>


