Tuesday, September 7, 2010

Soap Call using Javascript

There are many times now that I need to make a soap call to an XML web service.... from the client (javascript). If, for example, you need to update the database... but want to use Javascript to do so out of process - without a postback...and with minimal data passed to the server... this is a great approach.

After a lot of research and testing I have found and do recommend the following js tool for any of my colleagues:


Using this, it is a simple trick to call the database...

var url = "../../ws/MyWebService.asmx";

function HelloWorld() {
var pl = new SOAPClientParameters();
pl.add("yourName", "Robert the Great");
SOAPClient.invoke(url, "HelloTo", pl, true, Hello_CallBack);

function Hello_CallBack(resultData) {
alert("Hello_CallBack: " + resultData);