Click here to Skip to main content
15,166,099 members
Articles / Programming Languages / Javascript
Article
Posted 12 Feb 2009

Stats

169.1K views
6.2K downloads
42 bookmarked

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
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)

Share

About the Author

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

Comments and Discussions

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