<script>$ (document). Ready (function () { varUsername = "Admin"; varPassword = "123456";
/ *==js Call WebService interface using Http-post mode (ie debug only) = =*/ //var host_url = "Http://localhost/Interface/Login.asmx/Login?" Username= "+ UserName +" &password= "+ Password; varurl = "Http://localhost/Interface/Login.asmx/Login"; varXmlHttp =NewActiveXObject ("Microsoft.XMLHTTP"); Xmlhttp.open ("POST", URL,false); Xmlhttp.setrequestheader ("Content-type", "application/x-www-form-urlencoded"); Xmlhttp.send ("Username=" + UserName + "&password=" + Password); if(Xmlhttp.readystate = = 4) { if(Xmlhttp.status = = 200) {document.getElementById ("Page"). InnerHTML =Xmlhttp.responsetext; } Else{alert ("Not 200! =" +xmlhttp.status); } } Else{alert ("Not 4! =" +xmlhttp.readystate); } /*==js Call WebService interface using SOAP (ie debug only) = =*/ //SOAP1.2 Request Data Format (please refer to Http://localhost/Interface/Login.asmx/Login?op=Login) vardata; Data= ' <?xml version= ' 1.0 ' encoding= ' utf-8 '?> '; Data= Data + ' <soap12:envelope xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd= "http://www.w3.org/ 2001/xmlschema "xmlns:soap12=" Http://www.w3.org/2003/05/soap-envelope ">"; Data= Data + ' <soap12:Body> '; Data= Data + ' <login xmlns= ' http://mmp.test.com/DataInterface/' > '; Data= Data + ' <UserName> ' +username; Data= Data + ' </UserName> '; Data= Data + ' <Password> ' +password; Data= Data + ' </Password> ';Data= Data + ' </Login> '; Data= Data + ' </soap12:Body> '; Data= Data + ' </soap12:Envelope> '; varXMLHTTP =NewActiveXObject ("Microsoft.XMLHTTP"); Xmlhttp.open ("POST", "Http://localhost/Interface/Login.asmx",false); Xmlhttp.setrequestheader ("Content-type", "Application/soap+xml"); Xmlhttp.send (data); document.getElementById ("Page12"). InnerHTML =Xmlhttp.responsetext; }); </script>
Invoking the WebService interface with JS