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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XmlHttp waitForResponse causing error in Windows Service

Status
Not open for further replies.

Craftor

Programmer
Feb 1, 2001
420
NZ
Hi all

I'm using an XmlHTTP object to retrieve information from Outlook Web Access. I'm calling the send() method asynchronously and then trying to determine in a loop whether the readyState is 4 (COMPLETE). If I run this code in a Windows Form or a Console Application - it runs fine but if I try to run it from a Windows Service - it returns the error "The handle is invalid" when I try to check the readyState after calling the waitForResponse() method the first time.

Has anyone come across this error before?

My code is as follows:
Code:
MSXML2.ServerXMLHTTP40Class xmlHttp = new ServerXMLHTTP40Class();
xmlHttp.open("PROPFIND", serverUrl, true, username, password);
xmlHttp.setRequestHeader("SQL", folderQuery);
xmlHttp.setRequestHeader("Content-type", "text/xml");
xmlHttp.setRequestHeader("Depth", "1");

xmlHttp.send(null);

while (true)
{
        // error occurs the second time this is accessed.
	if (xmlHttp.readyState != 4)
	{
		// waiting
		xmlHttp.waitForResponse(5);
	}
	else
	{
		folderList = xmlHttp.responseText; 
		break;
	}
}

Thanks as always

Craftor
:cool:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top