XMLHTTP-Pls help

K

Kapil Shah

Hello everybody,
I am trying to develop code to use the correct version of XMLHTTP before
using it to send SOAP envelope to WebService . The code I have written
is as follows,

function getWebServiceResultsAfterInit() {

// Must be using IE for this to work
if(window.ActiveXObject){
// Create the XML Document object

var bDocument=false;

var aszDocumentProgIDs=[ "MSXML2.DOMDocument.4.0",
"MSXML2.DOMDocument.3.0",
"MSXML2.DOMDocument",
"MSXML.DOMDocument",
"Microsoft.XmlDom"];

for(var i=0;!bDocument && i<aszDocumentProgIDs.length; i++) {

try{

objXmlDoc=new ActiveXObject(aszDocumentProgramIDs);
bDocument=true;
}catch (objException){



}

} // End of For Loop

// Create the XML HTTP object
var bHttp= false;

var aszHttpProgIDs=["MSXML2.XMLHTTP.4.0",
"MSXML2.XMLHTTP.3.0",
"MSXML2.XMLHTTP",
"Microsoft.XMLHTTP"];


for (var i=0;!bHttp && i<aszHttpProgIDs.length; i++){

try{

objHttp= new ActiveXObject(aszHttpProgIDs);
bHttp=true;
} catch (objException) {

// error handling elided for clarity

}


}// End of For Loop

if(!bDocument ||!bHttp){
throw "MSXML not found on your computer.";

return;

}


However the code is not running and the error I am getting is Exception
thrown but not caught.. I am getting lost.. WOuld really appreciate it
if somebody helps me.

Thanks in advance..

Kapil
 
A

Alvin Bruney [MVP]

what's the point of these lines?

var aszDocumentProgIDs=[ "MSXML2.DOMDocument.4.0",
"MSXML2.DOMDocument.3.0",
"MSXML2.DOMDocument",
"MSXML.DOMDocument",
"Microsoft.XmlDom"];

for(var i=0;!bDocument && i<aszDocumentProgIDs.length; i++) {


your code should look like this:

var obj = new ActiveXObject("Microsoft.XMLHTTP");
if(obj != null){
obj.Open('GET','webform1.aspx'+'?__COMMAND='+command,false); obj.Send(); var
s = obj.responseText; alert(s)
} else alert('Unable to create client object');
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top