Link to home
Start Free TrialLog in
Avatar of newuser11
newuser11

asked on

MSXML2.ServerXMLHTTP


Hi,

I am using MSXML2.ServerXMLHTTP to access a web page which is located on my machine(localhost). During the "Send" I get the following error. Any thoughts??? I greatly appreciate your help.

     Set objXMLHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP")
     objXMLHTTP.Open "GET", "http://localhost/test/x.asp?par1=val1&par2=val2", False
     objXMLHTTP.Send

Error Type:
msxml3.dll (0x80072EE2)
The operation timed out
/test/x.asp, line 17

Thanks.
Avatar of hongjun
hongjun
Flag of Singapore image

One possible suggestion is do a loop until the readystate=4
Something like...

Set XMLHttp = CreateObject("Microsoft.XMLHTTP")
XMLHttp.async = false

Do Until XMLHttp .ReadyState = 4
' Wait until xmldoc is loaded before continuing.
Loop
...
...
Then on as normal.



hongjun
hey there hongjun!

Server.CreateObject("MSXML2.ServerXMLHTTP")!!!

Thank god for ASP.NET
hey!!!
b1xml2!!!
You are back?

hongjun
yep, check my points for the month =)
Yap!!! Just checked :)
Welcome !!!
Go reclaim your top spot for XML!!!

hongjun
Where have you been to? Busy must be...
I am also a bit busy.. Am actually studying for final exams.. Studying Financial Accounting at the moment and kinda too bored over this subject and ..haha


hongjun
and climbing back in XML, ASP.NET <GRIN>...
try

Server.CreateObject("MSXML2.ServerXMLHTTP.3.0")
or
Server.CreateObject("MSXML2.ServerXMLHTTP.4.0")

and make sure this page runs without xmlhttp request  >  http://localhost/test/x.asp?par1=val1&par2=val2
you can;t call to yourself!!

/test/x.asp, line 17
we need better glasses...  :)
and sometimes even fortune telling and mind reading abilities as well =)
haha
Avatar of newuser11
newuser11

ASKER

actually I am not calling the same page...

test/x.asp is calling http://localhost/test/y.asp?par1=val1&par2=val2
oops..! did you try my suggestions then?
yes. I did. But the actual page "y.asp" is taking more than 2min to render the data. I tried to set objXMLHTTP.waitForResponse to 9000 seconds. But this is not working...

Here is the function code

Function GetHTML(strURL)
     response.write(strURL)
     Dim objXMLHTTP, strReturn
     Set objXMLHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP.4.0")
     objXMLHTTP.Open "GET", strURL, true
     Call objXMLHTTP.Send
                    
       'Turn off error handling
  On Error Resume Next
 
  'Wait for up to 3 seconds if we've not gotten the data yet
  If objXMLHTTP.readyState <> 4 then
    response.write(objXMLHTTP.readyState)
    objXMLHTTP.waitForResponse 9000
  End If

  'Did an error occur?  If so, use a default value for our data
  If Err.Number <> 0 then
    response.write("Error")
    strData = "some default text..."
  End If

     strReturn = objXMLHTTP.responseText
     Set objXMLHTTP = Nothing
     GetHTML = strReturn
End Function
one minute=60000
two minutes=120000
three minutes=180000
and so on...
ASKER CERTIFIED SOLUTION
Avatar of davidlars99
davidlars99
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
waitForResponse is not waiting for specified amount of seconds. It's giving the error "The operation has been canceled"

that's because you need to change "true" to "false" like so

xmlServerHttp.open("GET", "http://localhost/sample.asp", False)

true is a boolean indicator of whether the call is asynchronous or not, for true you need to specify a callback function for onreadystatechange event
I forgot to mention that I think onreadystatechange is not supported for ASP, but I'm not 100% sure  :o)
if you want to try onreadystatechange then do it like this

Dim _response

Private Function _ReadyStateChange()
    _response=xmlServerHttp.responseText
End Function

Set xmlServerHttp=Server.CreateObject("MSXML2.ServerXMLHTTP.4.0")
xmlServerHttp.OnReadyStateChange = _ReadyStateChange
xmlServerHttp.open("GET", "http://localhost/sample.xml", True)
xmlServerHttp.send()
While xmlServerHttp.readyState <> 4
    xmlServerHttp.waitForResponse(1000)
Wend

or without

While xmlServerHttp.readyState <> 4
    xmlServerHttp.waitForResponse(1000)
Wend
any luck..?