Advertisement

01.25.2005 at 11:02AM PST, ID: 21288132
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.8

ServerXMLHTTP waitForResponse not working asynchronously

Asked by dbmercer in Extensible Markup Language (XML)

Tags: , ,

I am trying to detect errors while using ServerXMLHTTP asynchronously, but it appears that readyState remains 1 when an error occurs, and the only way I have found for detecting the error is to use waitForResponse, but that does not seem to work asynchronously (which is contrary to its advertised behavior).  Does anyone have any advice?

Here's how to reproduce my problem:

1. First, I set up an ASP page that will purposely stall 10 seconds before returning a response.  Here is the source for it:

wait10.asp:
--------------------------------------------------------------------------------
<script runat="server" language="JScript">
      var before = new Date;
      var now;
      for (now = new Date; now < before.valueOf() + 10e3;) now = new Date;
</script>
<%= before %> and <%= now %>
--------------------------------------------------------------------------------

2. Next I ran the following script:

testasynch.js
--------------------------------------------------------------------------------
var exception;

var http = new ActiveXObject("Msxml2.ServerXMLHTTP.4.0");

// First try a known good URL.

http.open("GET", "http://localhost/wait10.asp", true);
http.send();
WScript.Echo("GOOD SEND:\t" + new Date + "\tREADY-STATE:\t" +
http.readyState);
while (!http.waitForResponse(1))
{
      // If waitForResponse works as advertised, we expect this to loop ~9x
      WScript.Echo("WAITING:\t" + new Date + "\tREADY-STATE:\t" + http.readyState);
}
WScript.Echo("COMPLETE:\t" + new Date + "\tREADY-STATE:\t" + http.readyState);


// Now try a known bad URL.

http.open("GET", "http://localhost_bad/wait10.asp", true);
http.send();
WScript.Echo("GOOD SEND:\t" + new Date + "\tREADY-STATE:\t" +
http.readyState);
try
{
      while (!http.waitForResponse(1))
      {
            WScript.Echo("WAITING:\t" + new Date + "\tREADY-STATE:\t" +
http.readyState);
      }
}
catch (exception)
{
      WScript.Echo(exception.description);
}
WScript.Echo("COMPLETE:\t" + new Date + "\tREADY-STATE:\t" + http.readyState);
--------------------------------------------------------------------------------

3. We would expect the "WAITING" line to output about 9x if waitForResponse were only waiting one second.  Instead, it appears to wait the full 10s, at which time it returns true because the response has been received.  With the second test, with the bad URL, waitForResponse appears to be the only way to detect the error, however, since readyState remains 1 and the other properties throw the error, "The data necessary to complete this operation is not yet available", and so this situation is indistinguishable from a long-running request.  Here's the output:

--------------------------------------------------------------------------------
GOOD SEND:      Tue Jan 25 11:08:13 CST 2005    READY-STATE:    1
COMPLETE:       Tue Jan 25 11:08:24 CST 2005    READY-STATE:    4
GOOD SEND:      Tue Jan 25 11:08:24 CST 2005    READY-STATE:    1
The server name or address could not be resolved

COMPLETE:       Tue Jan 25 11:08:26 CST 2005    READY-STATE:    1
--------------------------------------------------------------------------------

Thank-you in advance.
Start Free Trial
[+][-]02.03.2005 at 01:32PM PST, ID: 13219621

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.03.2005 at 02:08PM PST, ID: 13219989

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.03.2005 at 02:13PM PST, ID: 13220041

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.03.2005 at 02:22PM PST, ID: 13220123

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.03.2005 at 02:23PM PST, ID: 13220136

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.03.2005 at 02:26PM PST, ID: 13220160

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.03.2005 at 02:40PM PST, ID: 13220271

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Extensible Markup Language (XML)
Tags: waitforresponse, serverxmlhttp, complete
Sign Up Now!
Solution Provided By: sltco
Participating Experts: 1
Solution Grade: A
 
 
[+][-]02.03.2005 at 03:10PM PST, ID: 13220531

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.03.2005 at 03:18PM PST, ID: 13220621

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.03.2005 at 03:25PM PST, ID: 13220691

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.03.2005 at 03:35PM PST, ID: 13220798

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32