Team,
From a windows service, we consume a web service on another server and
occasionally receive System.Net.WebException: The underlying connection was
closed:. For some clients we call, we do not see this as we ran into this
previoulsy, made a posting, and received some suggested code to resolved.
The code was put in their proxy classes and was this...
protected override WebRequest GetWebRequest(Uri uri)
{HttpWebRequest webRequest = (HttpWebRequest) base.GetWebRequest(uri);
webRequest.KeepAlive = false;
return webRequest; }
However, for the web service in question, we could not put that override
because it's proxy class inherits from class
Microsoft.Web.Services2.WebServicesClientProtocol (instead of
System.Web.Services.Protocols.SoapHttpClientProtoc ol ). Even though the code
builds ok - we recieve invalid cast exception at runtime on the first line.
Thus I either need a new solution for avoiding the System.Net.WebException:
The underlying connection was closed error as the original code snipet does
not work in proxy classes derived from
Microsoft.Web.Services2.WebServicesClientProtocol.
By the way we are deriving from
Microsoft.Web.Services2.WebServicesClientProtocol so we can send soap
security tokens in header.
Need soon! Thanks,
Tim