This is my asp code
<%
http = server.createobject(\"microsoft.xmlhttp\")
http.open \"post\", servleturl, false
http.setrequestheader \"content-type\", \"a
Using waitForResponse method of ServerXMLHTTP
instance after the .Send
call is a proper way, I'd recommend.
Also to use .WaitForResponse
, need to make an asynchronous call by setting True
the third parameter of .Open
method.
Const WAIT_TIMEOUT = 15
Dim http
Set http = Server.CreateObject("MSXML2.ServerXMLHTTP")
http.open "POST", servleturl, True 'async request
http.setrequestheader "content-type", "application/x-www-form-urlencoded"
http.setrequestheader "accept-encoding", "gzip, deflate"
http.send "request=" & sxml
If http.waitForResponse(WAIT_TIMEOUT) Then 'response ready
http_response = http.responseText
Else 'wait timeout exceeded
'Handling timeout etc
'http_response = "TIMEOUT"
End If
Set http = Nothing
You can also keep using the synchronous request by calling "SetTimeouts" like this:
<%
Dim http
Set http = Server.CreateObject("MSXML2.ServerXMLHTTP")
http.SetTimeouts 600000, 600000, 15000, 15000
http.Open "post", servleturl, false
http.SetRequestHeader "content-type", "application/x-www-form-urlencoded"
http.SetRequestHeader "accept-encoding", "gzip, deflate"
http.Send "request=" & sxml
http_response = http.responsetext
%>
See here for docs.
The parameters are:
setTimeouts (long resolveTimeout, long connectTimeout, long sendTimeout, long receiveTimeout)
The setTimeouts method should be called before the open method. None of the parameters is optional.