I am trying to access the XMLHTTPRequest.open method. I even included netscape.security.PrivilegeManager.enablePrivilege ("UniversalBrowserRead");
but still not working.
I use javascript and HTML to access the WebService.
Any help would be really wonderful
code
<html> <Head> <Title>Calling A WebService from HTML </Title> </Head>
<Body onload='GetDataFrmWS()'> <form name="Form1" id="Form1" runat="server" method="post"> <div id="DisplayData" > </div> <div id="Menu2"></div>
</form>
<script language='javascript'>
var objHttp; var objXmlDoc;
function GetDataFrmWS() { alert('IM Here'); var func = getDataFromWS();
}
function getDataFromWS() {
if(window.ActiveXObject) { try { objHttp = new ActiveXObject('Msxml2.XMLHTTP');
} catch (ex) { objHttp = new ActiveXObject('Microsoft.XMLHTTP'); }
} else if (window.XMLHttpRequest) { objHttp = .XMLHttpRequest(); netscape.security.PrivilegeManager.enablePrivilege( "UniversalBrowserRead" ); }
strEnvelope = '< soap: Envelope xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns: xsd = "http://www.w3.org/2001/XMLSchema" xmlns: soap = "http://schemas.xmlsoap.org/soap/envelope/" > ' + '& ; : >' + '< HelloWorld xmlns = "http://tempuri.org/" >' + '< Dummy xsi: type = "xsd: string" > Hello </Dummy>' + '</HelloWorld>' + '& ;/: >' + '& ;/: >';
var szUrl; szUrl = ' http://kamadhenu/Quoteme/GetCategories.asmx?op=HelloWorld '; objHttp.onreadystatechange = HandleResponse;
objHttp.open('POST', szUrl, true); objHttp.setRequestHeader('Content-Type', 'text/xml'); objHttp.setRequestHeader('SOAPAction', ' http://tempuri.org/HelloWorld '); objHttp.send(strEnvelope);
}
HandleResponse() {
if (objHttp.readyState == 4) {
if (window.ActiveXObject) { objXmlDoc = ActiveXObject ( "Microsoft.XMLDOM" ); objXmlDoc.async = ""; objXmlDoc.loadXML(objHttp.responseText); var nodeSelect = objXmlDoc.getElementsByTagName( "Menu1" ). item (0); var Menu2 = objXmlDoc.getElementsByTagName( "2" ). item (0); document.getElementById( 'DisplayData') innerHTML = nodeSelect.text;.
document.getElementById( 'menu2') innerHTML = Menu2.text. } { var Text = objHttp.responseText; var parser = new DOMParser(); objXmlDoc = parser.parseFromString(, /xml ); var Value = objXmlDoc.documentElement.childNodes [0].childNodes [0].childNodes [0].childNodes [0].childNodes [0].childNodes [0].childNodes [0].nodeValue; var Menu2 = objXmlDoc.documentElement.childNodes [0].childNodes [0].childNodes [0].childNodes [0].childNodes [0].childNodes [1].childNodes [0].nodeValue; var Menu3 = objXmlDoc.documentElement.childNodes [0].childNodes [0].childNodes [0].childNodes [0].childNodes [0].childNodes [1].childNodes [1].nodeValue; document.getElementById( 'DisplayData') innerHTML = ;.
document.getElementById( 'menu2') innerHTML = menu2. document.getElementById( 'menu2') innerHTML + = menu3. } }
}
</script > < input type='Button' = 'Click Me' onclick = 'GetDataFrmWS()' value = "Click Me!" /></; </ > </HTML>
code>