Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

winHttp Posting to slow server

Status
Not open for further replies.

ToddWW

Programmer
Joined
Mar 25, 2001
Messages
1,073
Location
US
I have really battled this one for about two days now. I am posting some xml to an http server and the following code works great.
Code:
objHttp.Open("POST","someurl.com",False)
objHttp.Send(xmlData)
The receiving server receives the XML, processes it, then we get an email back regarding the results. The problem is that the receiving server is buffering the response so we don't get a response until the processing is complete. Sometimes this can take up to a minute. So, I tried the following code.
Code:
objHttp.Open("POST","someurl.com",True)
objHttp.Send(xmlData)
This opens the connection in asynchronous mode and the call to Send() completes immediately. But it appears to abort the process because the receiving server does not get the post. So I did some research and I tried the following.
Code:
objHttp.Open("POST","someurl.com",True)
objHttp.Send(xmlData)
responseReceived = objHttp.WaitForResponse()
This works great. resposeReceived evaluates to True but this process takes just as long as the first option we were using. So I start playing with the timeout in the WaitForResponse method and tried the following.
Code:
responseReceived = objHttp.WaitForResponse(10)
Hmmm.. This was interesting. responseReceived evaluated to False however the 10 second wait was enough to get all of my post out of my client and into the server. The end result was a success.

So, my question is... Is there any method, or property (I've studied and tested most of them with this object) that can allow me to move on once the post is gone ? We don't need to see a result on the server during this process.

Any ideas would be greatly appreciated.

ToddWW
 
Whether you use a synchronous transmission or asynchronous transmission, the remote site is still going to take the same time to handle business. What WaitForresponse can do for you, however, is allow you to place the Send at the top of your code, then display/execute everything else you have planned for the page, then place the WaitForResponse at the very end. At this point you could just put a Response.Flush right before it and push all of the content you have built thus far to the end user.
Downside? The end user will get content and display, but the loading icon will still be going until that XML file has been transferred on the server.
Upside? The client sees the content for that page immediately.

Unfortunatly you are restricted in what you can force the web server to do. Reducing the WaitForResponse time is just saying "Only wait x time, if it isn't done then abort". You might be able to get around the whole issue but it would require something on a higher level of complexity. Ether some sort of server-side component to handle the work or a more complicated process of communications.

Example:
On the local server you could save the XML to a file and write it to a folder with a unique name. Then instead of sending the XML to the remote server you could simply send the filename. On the remote server you could have a file that you just append file names to and a scheduled .vbs script to run every minute and download any files listed in that file and then delete them (if the remote server is a nix server, you could do the samething as a cron job and bash script). This would get you around the waiting time, but gives you more points of possible failure.

-T

barcode_1.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top