Click here to Skip to main content
15,880,608 members
Articles / Programming Languages / Javascript

Calling Web Services From JavaScript - Using SOAP Client

Rate me:
Please Sign up or sign in to vote.
4.63/5 (15 votes)
12 Feb 2009CPOL 176.7K   6.2K   42   24
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.

C#
//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. :)

License

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


Written By
Web Developer
Turkey Turkey
Borned in İstanbul/TURKEY....
Loves İstanbul...

Comments and Discussions

 
Suggestionno se entiende nada Pin
Wilmer Rivera16-Apr-18 9:56
Wilmer Rivera16-Apr-18 9:56 
GeneralRe: no se entiende nada Pin
Nelek16-Apr-18 9:59
protectorNelek16-Apr-18 9:59 
QuestionAccess is denied in soapclient.js Pin
Member-clarence31-Jul-15 6:09
professionalMember-clarence31-Jul-15 6:09 
GeneralGreat Example, works in all browser Pin
Tahir Saleem19-Feb-13 0:33
Tahir Saleem19-Feb-13 0:33 
GeneralRe: Great Example, works in all browser Pin
Gökmen BULUT23-Feb-13 12:38
Gökmen BULUT23-Feb-13 12:38 
GeneralMy vote of 5 Pin
Tahir Saleem19-Feb-13 0:30
Tahir Saleem19-Feb-13 0:30 
GeneralMy vote of 4 Pin
Unareshraju22-Jul-12 23:15
Unareshraju22-Jul-12 23:15 
GeneralMy vote of 5 Pin
Manoj Kumar Choubey27-Mar-12 4:11
professionalManoj Kumar Choubey27-Mar-12 4:11 
GeneralWebService Pin
ramalingajm25-Apr-11 1:06
ramalingajm25-Apr-11 1:06 
Generalsoapclient.js and firefox 3 and 4 Pin
Member 23138416-Apr-11 1:32
Member 23138416-Apr-11 1:32 
Questionnot work in firefox Pin
nimax3d116-Oct-10 3:16
nimax3d116-Oct-10 3:16 
QuestionRe: not work in firefox Pin
rayrogar30-Oct-12 10:32
rayrogar30-Oct-12 10:32 
GeneralOK. Pin
amity201018-Aug-10 2:36
amity201018-Aug-10 2:36 
QuestionWeb Service Error : "The underlying connection was closed: The connection was closed unexpectedly." Pin
ganesh_barhate27-Jul-10 1:36
ganesh_barhate27-Jul-10 1:36 
GeneralUsing WebService Created in Java Pin
rraiyarela3-Jun-10 20:02
rraiyarela3-Jun-10 20:02 
Generalhi Please help me Pin
bhaveshcode27-Jul-09 20:17
bhaveshcode27-Jul-09 20:17 
GeneralRe: hi Please help me Pin
spina20-Aug-09 16:59
spina20-Aug-09 16:59 
GeneralRe: hi Please help me Pin
pietjepietje8-Oct-09 3:12
pietjepietje8-Oct-09 3:12 
GeneralRe: hi Please help me Pin
KiMO.133721-Aug-11 21:55
KiMO.133721-Aug-11 21:55 
QuestionJaume Pin
enric@mcrit.com22-May-09 1:27
enric@mcrit.com22-May-09 1:27 
GeneralNot working in Firefox [modified] Pin
SlingBlade29-Apr-09 18:46
SlingBlade29-Apr-09 18:46 
GeneralRe: Not working in Firefox Pin
packets27-Nov-10 17:44
packets27-Nov-10 17:44 
GeneralRemote Web Service Pin
smoore418-Feb-09 2:01
smoore418-Feb-09 2:01 
GeneralRe: Remote Web Service Pin
Gökmen BULUT6-Mar-09 3:39
Gökmen BULUT6-Mar-09 3:39 

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

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