3


We are using Spring 4 WebServiceTemplate to contact a WCF web service. One of the items we send across to this web service are images (JPEG format). For some of the cases when the image is slightly bigger (about 22KB), we get the following error:

<pre><code>org.springframework.ws.client.WebServiceIOException: I/O error: Connection reset; nested exception is java.net.SocketException: Connection reset</pre></code>

If we do not send the image at all, this error does not happen. So it clearly seems to be related to the payload size because with smaller-sized images or with no images there is no issue. This 22KB is approximately twice the size as the image size during other invocations.

We have tried switching from SaajSoapMessageFactory to AxiomSoapMessageFactory as suggested here, but the result is same.

class <className> extends WebServiceGatewaySupport {
      <className>() {
          super(new AxiomSoapMessageFactory());
          AxiomSoapMessageFactory messageFactory =
            (AxiomSoapMessageFactory) getMessageFactory();
          messageFactory.setPayloadCaching(false);
          ...
      }
      ...
}

Does anyone how to fix this?

Paddy
  • 3,472
  • 5
  • 29
  • 48

1 Answers1

1

The real problem was not about SaajSoapMessageFactory or AxiomSoapMessageFactory. The application was trying to send Base64 encoded image strings in the call to web service and in few cases this encoded string was too long (although entire message size was not awfully big enough to warrant AxiomSoapMessageFactory).

The problem was resolved when we replaced "Text" binding with "Mtom" in the webservice configuration (WCF) and added the marshaller.setMtomEnabled(true) in the client code.

Paddy
  • 3,472
  • 5
  • 29
  • 48