Connection reset from a WCF Web Service

Here is an error message you may see, when calling WCF Web Services from java:
IOException retrieving the response: java.net.SocketException: Connection reset

As it may not be obvious the first time you see it, this may save you some time.

One reason for this behaviour is when the WCF endpint is expecting to see wsa:Action SOAP header in the request.

To find out if you are facing this case, you have to look inside the WSDL, and search for the policy that describes the contract for your endpoint.


<wsp:Policy wsu:Id="CustomBinding_Echo1_policy">
  <wsp:ExactlyOne>
    <wsp:All>
      <wsaw:UsingAddressing/>
    </wsp:All>
  </wsp:ExactlyOne>
</wsp:Policy>


To make this a concrete example, here is a sample WSDL. To find the policy, you will need to follow the import as the policy are not always advertized in the top-level document.

Here is how the import looks:

  <wsdl:import namespace="http://example.org/" location="http://.../WSAddressing10.svc?wsdl=wsdl1"/>


To get around this, make sure you have the proper wsa:Action value in the reques, as in this sample:


<env:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
  <wsa:Action>http://example.org/action/echoIn</wsa:Action>
  <wsa:ReplyTo>
    <wsa:Address>http://www.w3.org/2005/08/addressing/anonymous</wsa:Address>
  </wsa:ReplyTo>
  <wsa:To>http://.../WSAddressing10.svc/Soap12</wsa:To>
</env:Header>


Another thing to watch for is the value used for the SOAP Action (SOAP 1.1) or the action attribute in the Content-type (for SOAP 1.2).

Here is a SOAP 1.2 sample:
Content-type: application/soap+xml; charset=UTF-8;
action="http://example.org/action/echoIn"


Remember that the two value must be identical, for the messages to be processed by WCF. Otherwise, you will get a "connection reset" error message at best, or see the connection left open indefinitely.

Happy SOA coding

-Ecco

Comments

James P said…
Yep, I ran into this problem in both Axis2 and Metro. It took me a day to figure it out. Thanks for posting!

Popular posts from this blog

Changing the version of JDK used by JDeveloper

Why ws-rx ?