Click here to Skip to main content
Click here to Skip to main content

Calling Web Services From JavaScript - Using SOAP Client

, 12 Feb 2009
Rate this:
Please Sign up or sign in to vote.
We can call any web service method using JavaScript soap client
html_small.JPG

Introduction

This article will show you how to make a web service call using only HTML markup and JavaScript.

Background

This article is based on JavaScript SOAP Client on http://www.codeplex.com/JavaScriptSoapClient.

Using the Code

Just copy and and change the scripts and markups. You can see a JavaScript example below.

//Calls Hello World Web Method.
var url = document.location.href.replace("default.htm", "webservicedemo.asmx");
	
// DEMO 1
function HelloWorld()
{
	var pl = new SOAPClientParameters();
	SOAPClient.invoke(url, "HelloWorld", pl, true, HelloWorld_callBack);
}
function HelloWorld_callBack(r)
{
	alert(r);
}
// End of script.		

That's all guys.

Points of Interest

I already knew how to make a web service call from JavaScript using webservice.htc. I could not make these calls on browsers other than Internet Explorer. So I searched and found this method. It is so simple to use. Add soapclient.js to your project and some code like the above. Then call it with something like button, etc.

History

  • 12th February, 2009: Initial post

I will be waiting for your questions. If you like it, please vote. Smile | :)

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Gökmen BULUT
Web Developer
Turkey Turkey
Borned in İstanbul/TURKEY....
Loves İstanbul...

Comments and Discussions

 
GeneralGreat Example, works in all browser PinmemberTahir Saleem19-Feb-13 0:33 
GeneralRe: Great Example, works in all browser PinmemberGökmen BULUT23-Feb-13 12:38 
GeneralMy vote of 5 PinmemberTahir Saleem19-Feb-13 0:30 
GeneralMy vote of 4 PinmemberUnareshraju22-Jul-12 23:15 
GeneralMy vote of 5 Pinmembermanoj kumar choubey27-Mar-12 4:11 
GeneralWebService Pinmemberramalingajm25-Apr-11 1:06 
Generalsoapclient.js and firefox 3 and 4 PinmemberMember 23138416-Apr-11 1:32 
Questionnot work in firefox Pinmembernimax3d116-Oct-10 3:16 
QuestionRe: not work in firefox Pinmemberrayrogar30-Oct-12 10:32 
GeneralOK. Pinmemberdilip201018-Aug-10 2:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web03 | 2.8.140814.1 | Last Updated 12 Feb 2009
Article Copyright 2009 by Gökmen BULUT
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid