The underlying connection was closed when using a WSDL web service
- by joshlrogers
I am trying to consume this WSDL service:
Transit Time Service
I successfully connect and get a response the first time but on subsequent calls I receive the exception:
The underlying connection was closed: A connection that was expected to be kept alive was closed by the server.
I overrode the GetWebRequest in the reference.cs file as such:
protected override System.Net.WebRequest GetWebRequest(Uri uri)
{
HttpWebRequest webRequest = (HttpWebRequest)base.GetWebRequest(uri);
webRequest.KeepAlive = false;
return webRequest;
}
This hasn't yielded any improvement. I am at a loss as to what options I have now, does anyone have any other ideas that I could try so that I may avoid this error?
Thanks in advance!
Josh