Consuming a Web Service from an HTML Page
page 1 of 5
Published: 05 Sep 2005
Unedited - Community Contributed
Web services are commonly consumed from server-side web applications using sophisticated languages such as VB.NET, C#, and Java. Rajesh Toleti demonstrates that Web services may also be consumed from client-side HTML pages with the help of JavaScript.
by Rajesh Toleti
Average Rating: 
Views (Total / Last 10 Days): 52691/ 23

View Entire Article

User Comments

Title: eee   
Name: eee
Date: 2012-11-19 4:43:17 AM
Title: FOR non IE browsers   
Date: 2011-10-11 10:07:46 AM
Hi all, Please use the technique described in the below article if you are using any browser other than IE.
Title: Problem   
Name: ashish Mittal
Date: 2011-02-22 2:15:43 AM
i m trying to execute it and getting "undefined" result..
Same happening with my webservice too..what could be the problem?
my email is
Title: only working IE not in othe browsers   
Name: Hardeep Singh
Date: 2011-01-20 2:02:00 AM
Comment: only working IE
Title: Webservice is not consuming Not working for Safari   
Name: Narendar Piryani
Date: 2010-07-24 6:39:47 AM
Good Article.. but not working for Safari, firefox or Chrome... only working for IE.
Title: with reference to MATTO CASATI   
Name: Zaf Khan
Date: 2008-11-27 7:52:51 PM
THanks Matto, :)

I used this link to transalate your page to ENGLISH....
Its the Best Translation of PROPER English yet!!!
Title: undefined error   
Name: Sheikh Abdul Jaweed
Date: 2007-08-31 11:35:26 AM
get the error as "undefined"
Title: "undefined" result   
Name: nis mo
Date: 2007-08-19 6:12:40 PM
i m trying to execute it and getting "undefined" result..
Same happening with my webservice too..what could be the problem?
my email is
Title: does this support firefox browser   
Name: kings
Date: 2007-08-18 3:49:58 AM
hey its ok in internet explorer but it does not work in fire fox ., how to invoke this operaitons in firefox
Title: Working IP address to get the country name   
Name: Harry
Date: 2007-07-11 9:10:42 AM
I tried with manu ipaddresses. can you please tell me with what ip address can i test this service
Title: Good   
Name: Mohammed Husamuddin
Date: 2007-06-18 2:00:31 AM
Hava this error, Line 19
Error : 'myWebService.IP2Country' is null or not an object
A Runtime Error has occured
Title: return value wrong   
Name: yogesh
Date: 2007-04-21 7:36:24 AM
Hey thanks for posting.
but i m trying to execute it and getting "undefined" result..
Same happening with my webservice too..what could be the problem?
Title: does not work on FireFox   
Name: Jah Hasangjekaj
Date: 2007-03-10 4:21:53 PM
How can I make this work in Firefox
Title: oh no...   
Name: fudi
Date: 2007-02-19 9:36:30 AM
i don't like such articles. it starts promising, but actually tells just half of the story. people who alreay know about web services and consuming them will understand anyway, all others are lost. why not provide the complete source code (also the web service)? i'm sure you'd know how to explain, so why don't you?
Title: Otto   
Name: Shiney Tracky Dacks
Date: 2006-10-05 1:28:13 AM
Anthony Kasses what are you talking about ???
Title: Great Explanation!   
Name: DP
Date: 2006-07-16 5:19:22 PM
Well, I have seen a dozen or more articles on how to use web services. This is by far the most basic explanation of how to get a web service to work. From here you can move t o WSDL, SOAP, UDDI etc., but this was great (easier than w3schools). Oh, as for not working in other browsers, I believe the behavior attribute is only recognized by MSIE, so the problem is not your code, but the other browsers.
Title: Consuming Web Service in ASP.NET   
Name: LeProgrammeur
Date: 2006-06-11 9:13:02 PM

I posted a tutorial showing the basic steps to consume a web service in at the link
Go to the link above and search for: Consuming a Web Service
There is also a chat room in this same link where I try to spend as more time as I can to answer questions.
Title: Complex Return Values via HTC   
Name: Dan Fitzgerald
Date: 2006-03-06 5:24:02 PM
Great article!

I was wondering about the return values. You mentioned that only simple return values can be returned. So, if I am interfacing with an existing web service that returns say a struct such as:

struct Return
int ID;
string the_string;

Is there a way to parse through this as a return value at all or do I need to ask the web service provider to modify to return a comma-separated string for example?

Thank you,

Title: Cross Domain Calls   
Name: Ryan Smith
Date: 2005-12-19 10:27:01 AM
That was a great article. Is there anyway to make a webservice all across different domains? Or is the only way to accomplish this to handle it on the server site?
Title: Great Article   
Name: Don Logan
Date: 2005-12-06 9:55:30 AM
Great clear article on Web services.
Title: which protocol is this webservice uisng in communaication   
Name: Deepak
Date: 2005-11-28 6:16:58 AM
this is an excellent stuff..but has few drawback..if only run in IE..and i just want to knwo which protocol(GET or POST or SOAP with HTTP) is it using..bcoz GET and POST are not secure me regarding this to
Title: Software Developer   
Name: Ram
Date: 2005-11-19 12:25:26 AM
Really this posting is very informative, but it is not complete.The description abt the getresult function and useservice is not complete..can u give me the complete details.

My mail-ID is :
Title: Very well explained   
Name: Anthony Kasses
Date: 2005-11-14 7:37:44 PM
Great article, ...however I'm getting
"This page is accessing information that is not under it's control. This poses a security risk. Do you want to continue?" (yes/No).

I'm using Win 2003 and IE 6.

Any thought?
Title: Goood Work   
Name: Steve Rock
Date: 2005-11-14 5:34:00 AM
Nice Work
Title: mr   
Name: alok
Date: 2005-10-25 8:53:46 AM
good stuff!!!
Title: Test with error   
Name: came
Date: 2005-10-21 3:05:03 AM
Hava this error, Line 19
Error : 'myWebService.IP2Country' is null or not an object
A Runtime Error has occured
Do you wish to Debug?
Title: Old technology..   
Name: Carlos
Date: 2005-10-20 11:32:18 AM
Try AJAX, XmlHttp or something else.. because your solution has too much limitations for serius web develpment..
Title: Another way (cross browser!)   
Name: Matto Casati
Date: 2005-10-20 6:02:05 AM
In my article ( you can find another way to consuming a Web Service with AJAX. My solution use pure javascript + XMLHttp and it's cross-browser (tested on IE, Moz, FireFox and Safari). The article is only available in italian language, sorry (but... code is code!)
Title: SSE   
Name: Neeraj Badaya
Date: 2005-10-19 10:17:19 PM

This is now obsolete now you have much better option of XMLHTTP which will work fine from the Javascript and need not to be include also.

Yes, it will work only for IF-5.0 and greater.
Title: Only in IE   
Name: lordm
Date: 2005-10-11 12:05:39 PM
Yeah, but this only works in IE. What about FF? Maybe use XMLHTTP, AJAX or something..
Title: create a proxy web service   
Name: Bit Banger
Date: 2005-10-10 2:48:48 PM
I _love_ this article. I can use it to excellent effect in many places in my application.

Anyone care to post the code for creating a proxy for ""?
Title: Web services using javascript   
Name: K.Senthil Kumar (Sensoft2000)
Date: 2005-10-07 11:18:07 PM
Wow.. Its really new information to me...
Title: programer   
Name: s k yadav
Date: 2005-10-07 4:17:07 PM
I find this artical intresting. It is good..........hope you too
Title: Returning Complex Types   
Name: Mark Hildreth
Date: 2005-10-07 3:17:52 PM
It is possible to return complex types from the webservice behavior, just make the webservice return type a struct with public properties. You can also return arrays or expose public properties that are arrays within a struct.
Title: Major Limitation   
Name: Ravi K
Date: 2005-09-16 3:47:07 PM
Good article, but this only works with Internet Explorer, which I think is a major limitation.
Title: Technical Associate   
Name: Pavan Kumar C
Date: 2005-08-31 6:39:25 AM
Great post that gives a clear understanding about the concept.

Product Spotlight
Product Spotlight 

Community Advice: ASP | SQL | XML | Regular Expressions | Windows

©Copyright 1998-2024  |  Page Processed at 2024-04-18 4:31:58 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search