views:

667

answers:

1

I am getting an error using the MsXml.ServerXmlHttp object from JScript under classic ASP when the call is asynchronous. The error message is "cannot find window class"


The environment is: Windows Server 2003 SP2; IIS v6; Classic ASP; JScript

When ServerXmlHttp.open is called with asynch = true the error occurs on the send method. When ServerXmlHttp.open is called with asynch = false the error doesn't occur

The code works on a test environment which has all the same versions of major products (although it has not been kept identical to the production environment)

In the test environment the code works with both a synchronous and an asynchronous open

The error occurs when using MSXML2.ServerXMLHTTP.6.0 MSXML2.ServerXMLHTTP.4.0 MSXML2.ServerXMLHTTP.2.0

The code fails in the same way regardless of the URL: google.com and stackoverflow.com fail just like the actual page I need to call

In the test environment google.com, stackoverflow.com and the page I need to call all work.

The error occurs regardless of whether I use a GET or a POST

The error occurs regardless of the headers.

The error occurs regardless of whether the protocal is HTTP or HTTPS.

The error happens very fast - almost definitely client-side.

The error DOES NOT occur when the connection is synchronous.

I have reinstalled MSXML6.msi

I have used "proxycfg.exe -d" to configure the internet stack to NOT use a proxy. (http://support.microsoft.com/kb/289481/)


Here is an indicative code sample (I've simplified it because I don't think the code is the problem):

var xmlServerHttp = Server.CreateObject("MSXML2.ServerXMLHTTP.6.0");
xmlServerHttp.open("POST", "http://some-url.com", true); //true causes error

xmlServerHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

xmlServerHttp.send("some=values&some=othervalues"); //error happens here

var responseXML;
var stateok = false;
var numOfWaits = 10;      
do {
    if (xmlServerHttp.readyState == READYSTATE_COMPLETED) {
     responseXML = String(xmlServerHttp.responseText);
     stateok = true;
    }
    else {
        xmlServerHttp.waitForResponse(1);
    }
 } while (!stateok && --numOfWaits > 0);

This code throws the error: "cannot find window class" on the xmlServerHttp.send call.

This is what MSDN says about the error (http://msdn.microsoft.com/en-us/library/ms820745.aspx)

An application tried to use a window class that was not an application-specific class registered with the system or one of the predefined control classes (such as BUTTON, LISTBOX, SCROLLBAR, and so on).

This knowledge base article (http://support.microsoft.com/kb/303326) contains the following asynchronous-specific note:

ServerXMLHTTP does not use Urlmon.dll. However, when you use ServerXMLHTTP in asynchronous mode, you also need this message pump because the parser fires the event by posting messages back to the thread.

Urlmon.dll does exist in the system32 folder of the server. However it doesn't exist on the test server where the code works in asynchronous mode :S. (I didn't explicitly install urlmon.dll - it was just there when I went to look for it.)

My guess is that there is some configuration or installation problem on the server. Maybe a MSXML depedency is missing. But I've don't know how to investigate further. Does anyone have any suggestions?

In particular, can anyone tell me:

  • What the dependencies of MsXml.ServerXmlHttp are?

    or how I can figure them out.

  • What does the error message "cannot find window class" mean in this context?

  • Are there any settings or configurations which are specific to asynchronous HTTP calls?

Thanks for reading this far.

A: 

The single threaded nature of ASP with COM objecst will not allow you to have handle async events as you might think.

One might think this was possible by refering to an event handler declared in global.asa, but I doubt that will work.

Your code is totally pointless, since you're trying to duplicate exactly what async=false does. You can control the timeout using the setTimeout() method.

thomask