Visual Studio 2003 で開発されたループで同じ Web サービスを呼び出すプログラムに問題があります。次のエラーが発生し続けます。
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)
メソッドのアドレスOpenRead(String address)
は有効です。デバッグして、アドレスを取得し、ブラウザーで wsdl を表示できます。
このエラーを回避する方法がわかりません。私のメソッドは、ストリームを開くたびにストリームを閉じます。ただし、エラーが発生しているため、この行に到達していないようですOpenRead()
スレッドプールを空にして、ある種の方法で最初からやり直す方法はありますか? アプリケーションを実行し、Web サービスをホストするマシンを再起動しようとしましたが、うまくいきませんでした。また、machine.config ファイルの最大ワーカー スレッドを 75 に増やしてみましたが、運もありませんでした
このアプリケーションは、まったく同じ構成の他の 2 つの環境で実行しているため、一般的に機能することがわかっています。
これは、Web サービスを呼び出すループの一部です。
try
{
returnValue = WebServiceProxy.CallWebService(
transaction.WebServiceURL, transaction.WebServiceName,
transaction.Request.MethodName, args);
}
Web サービスを呼び出すプロキシ クラスは静的クラスです。
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();