pXML= Product_Request
set http= server.Createobject("MSXML2.ServerXMLHTTP")
http.Open "GET", "http://test.com/Data_Check/Request.asp?XML_File=" & pXML , False
http.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
http.send
I need to send request with above asp code for the above URL. But i no need response from that server.
After sending the request, it waits for the response.
How do I write this so that it doesn't block while waiting for the response?
You may be able to use the WinHTTPRequest object directly instead (this is what underlies ServerXMLHTTP). It has an additional method which might be useful the WaitForResponse
method.
Set winHttpRequest = CreateObject("WinHttp.WinHttpRequest.5.1")
winHttpRequest.Open "GET", "http://localhost/mypage.aspx", true
winHttpRequest.Send
''# Do other request normally here
winHttpRequest.WaitForResponse()
Note the Open
method has true
for its async
parameter. In this case Send
will return as soon as the request has been sent but before any response has been recieved. You can now do other things like make your other request in a normal synchronous manner. Once done you can make sure that the orginal request has completed by calling WaitForResponse
.
CAVEATs
- I've never done this on in ASP directly there is possibility that the call to
Open
might complain that the script environment doesn't "do asynchronous calls".
- There is an assumption on your part that it is ok to make the two requests at the same time. If they are to two different servers then that will be fine, if not its still possibly fine but there may be other complications.
- You are making requests to an ASP page, each request creates a new session on that server, just something to be aware of.
- There is an assumption on my part you aren't calling into the same server that your code is running on, if you are you may be headed for a thread pool dead lock.
I don't believe there is a way to determine that your request was successful without a response. So what's to determine the difference between no response and complete failure?
Change your Open request to Asynchronous (i.e. 3rd parameter to True). This will allow you to submit two requests at the same time. Then you get wait for both responses to arrive.
pXML = Product_Request
Set http = server.Createobject("MSXML2.ServerXMLHTTP")
http.Open "GET", "http://test.com/Data_Check/Request.asp?XML_File=" & pXML , True
http.Send
Set http2 = server.Createobject("MSXML2.ServerXMLHTTP")
http2.Open "GET", insert_code_for_your_second_url_here , True
http2.Send
http1.WaitForResponse
http2.WaitForResponse