• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2506
  • Last Modified:

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.
0
newuser11
Asked:
newuser11
  • 11
  • 6
  • 5
  • +1
1 Solution
 
hongjunCommented:
0
 
hongjunCommented:
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
0
 
b1xml2Commented:
hey there hongjun!

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

Thank god for ASP.NET
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
hongjunCommented:
hey!!!
b1xml2!!!
You are back?

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

hongjun
0
 
hongjunCommented:
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
0
 
b1xml2Commented:
and climbing back in XML, ASP.NET <GRIN>...
0
 
davidlars99Commented:
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
0
 
b1xml2Commented:
you can;t call to yourself!!

/test/x.asp, line 17
0
 
davidlars99Commented:
we need better glasses...  :)
0
 
b1xml2Commented:
and sometimes even fortune telling and mind reading abilities as well =)
0
 
hongjunCommented:
haha
0
 
davidlars99Commented:
huhu
0
 
newuser11Author Commented:
actually I am not calling the same page...

test/x.asp is calling http://localhost/test/y.asp?par1=val1&par2=val2
0
 
davidlars99Commented:
oops..! did you try my suggestions then?
0
 
newuser11Author Commented:
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
0
 
davidlars99Commented:
one minute=60000
two minutes=120000
three minutes=180000
and so on...
0
 
davidlars99Commented:
so you need to do

While xmlServerHttp.readyState <> 4
    xmlServerHttp.waitForResponse(1000)
    strHTML=strHTML & xmlServerHttp.responseText
Wend

not sure about  strHTML=strHTML & xmlServerHttp.responseText in the LOOP but you can always try it like this


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

0
 
newuser11Author Commented:
waitForResponse is not waiting for specified amount of seconds. It's giving the error "The operation has been canceled"

0
 
davidlars99Commented:
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
0
 
davidlars99Commented:
I forgot to mention that I think onreadystatechange is not supported for ASP, but I'm not 100% sure  :o)
0
 
davidlars99Commented:
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

0
 
davidlars99Commented:
or without

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

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 11
  • 6
  • 5
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now