Using a WebService with DHTML and Javascript

Michael Schwarz on Sunday, March 30, 2003
Labels

I have been asked several times how to use a WebService in a DHTML application on the internet using Scripting. Ok, I have created a small sample using Javascript and Microsoft.XMLDOM ActiveX objects (you have to use Internet Explorer 5 or higher).

XmlHttp.open("POST", "[http://localhost/mymethod.asmx](http://localhost/mymethod.asmx)", true);
XmlHttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
XmlHttp.setRequestHeader("SOAPAction", "[http://my-comany.com/RequestX](http://my-comany.com/RequestX)");
XmlHttp.onreadystatechange = 
new Function("try{if(XmlHttp.readystate==4){
ParseResponse(XmlHttp.responseXML);}
}catch(e){}");
XmlHttp.send(SoapEnvelope);

Download the complete script form http://www.schwarz-interactive.de/webservice.txt [1].

(Ok, this is my first Weblog,...!)