Chinh Do

WCF Client Error “The connection was closed unexpectedly” Calling Java/WebSphere 7 Web Service

First time here? Check out my greatest hits or look around in the archives, and consider subscribing to the latest posts via RSS or email. I am also on Twitter and Google Plus. Thanks for visiting.
23rd January 2010

WCF Client Error “The connection was closed unexpectedly” Calling Java/WebSphere 7 Web Service

If you get the following exception calling a WebSphere web service from your .NET WCF Client (service reference):

System.ServiceModel.CommunicationException: The underlying connection was closed: The connection was closed unexpectedly. —>  System.Net.WebException: The underlying connection was closed: The connection was closed unexpectedly.

Try adding this code before the service call:

System.Net.ServicePointManager.Expect100Continue = false;

More info on the 100-Continue behavior from MSDN.

posted in Dotnet/.NET - C#, Java, Programming | 2 Comments