1

I have an issue with a program that calls the same web service in a loop developed in Visual Studio 2003. I keep getting this error:

Unable to make web service call. Ceasing processing. Message:The request was aborted: The         request was canceled. 
System.Net.WebException: The request was aborted: The request was canceled. ---> System.InvalidOperationException: There were not enough free threads in the ThreadPool object to complete the operation. 
   --- End of inner exception stack trace ---
   at System.Net.HttpWebRequest.BeginGetResponse(AsyncCallback callback, Object state)
   at System.Net.HttpWebRequest.GetResponse()
   at System.Net.WebClient.OpenRead(String address)

The address in the OpenRead(String address) method is valid - I can debug, take the address and view the wsdl in a browser.

I'm not sure how to get around this error - my method closes the stream every time it opens it. How ever, it doesn't seem to get to this line anymore since the error is at OpenRead()

Is there a way to empty the threadpool and in a sort of way, start over? I've tried rebooting the machine that both runs my application and hosts the web service with no luck. I've also tried increasing the max worker threads in the machine.config file to 75 with also no luck

I know this application works in general because I have it running in two other environments with the exact same configuration.

Here is part of the loop that calls the web service

try
{
    returnValue = WebServiceProxy.CallWebService(
        transaction.WebServiceURL, transaction.WebServiceName, 
        transaction.Request.MethodName, args);
}

The proxy class that calls the web service is a static class:

public static object CallWebService(string url, string serviceName, 
    string methodName, object[] args)
{
    //Connect to web service and retrieve WSDL
    Stream stream = client.OpenRead(url + "?wsdl");

    ServiceDescription description = ServiceDescription.Read(stream);
    stream.Close();
4

0 回答 0