The underlying connection was closed when using a WSDL web service

Posted by joshlrogers on Stack Overflow See other posts from Stack Overflow or by joshlrogers
Published on 2010-01-07T19:00:01Z Indexed on 2010/05/19 14:10 UTC
Read the original article Hit count: 189

Filed under:
|
|

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

© Stack Overflow or respective owner

Related posts about wsdl

Related posts about c#