Hi there,
Today we experienced a lot of timeouts for a web mothod call. It takes long time to reach the timeout error page. What I want to do is to set a time limit for the execution of the mothod call. If I do not get anything within this time period, I will do something else instead of going to the timeout error page.
The code I'm using are
-----------------------------------------------------------
set xmlhttp = Server.CreateObject("Microsoft.XMLHTTP")
xmlhttp.open "GET", "http://10.1.1.1/webservices.asmx/Authentication UserName=" & userid & "&Password=" & acct, false
xmlhttp.send ""
if xmlhttp.readyState=4 then
if xmlhttp.status=200 then
'Load the responseText
else
'Error message
end if
else
'error message
end if
----------------------------------------------------------------
Before I reach the line of "if xmlhttp.readyState=4 then",
how can I know how much time has elapsed If this is a long time, I will do something else. Any hint is appreciated.
Thanks.
Yolande

How to limit the execution time for a web mothod call?
Jan Thordsen
I do not think that there is a way to set a timeout on the "Send" method. This will be done synchronously and is usually pretty quick. What takes long is usually receiving the response from this call.
It appears that you are passing False for the boolean parameter that indicates if the call should be made asynchronously. You should change that value to True if you want to send the request and continue processing until the response comes back.
As far as waiting a pre-defined amount of time for the response the you should use the ServerXMLHTTP object. Here is a sample of how to do this... just point the URL to a web resource that will take a long time to respond and you'll see the results.
Sample Code (vbscript)
----------------------
dim xmlhttp
set xmlhttp = CreateObject("Msxml2.ServerXMLHTTP")
xmlhttp.Open "GET", "http://localhost/SlowWebMethod.asmx/HelloWorld Minutes=1&iSleep=1", true
xmlhttp.send
' Wait 10 seconds... if we dont' have a response by then, just ignore and do something else
xmlhttp.waitForResponse 10 ' You can check readyState to see what the current status' is after 10 seconds.
Select Case xmlhttp.readyState
Case 0 MsgBox "Uninitialized"
Case 1 MsgBox "Loading - still waiting on full response"
Case 2 MsgBox "Loaded"
Case 3 MsgBox "Interactive"
Case 4 MsgBox "Completed - Response received in 10 seconds"
End SelectReferences
-----------------
ServerXMLHTTP Object
ServerXMLHTTP.open Method
ServerXMLHTTP.waitForResponse Method
ServerXMLHTTP.readyState Property
Thanks
-Todd Foust