【问题标题】:Spring Webservicetemplate Connection reset errorSpring Webservicetemplate连接重置错误
【发布时间】:2015-07-09 10:50:15
【问题描述】:


我们正在使用 Spring 4 WebServiceTemplate 联系 WCF 网络服务。我们发送到此 Web 服务的项目之一是图像(JPEG 格式)。对于某些图像稍大(约 22KB)的情况,我们会收到以下错误:

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

如果我们根本不发送图像,则不会发生此错误。所以它显然似乎与有效载荷大小有关,因为使用较小尺寸的图像或没有图像没有问题。这 22KB 大约是其他调用期间图像大小的两倍。

我们尝试按照here 的建议从SaajSoapMessageFactory 切换到AxiomSoapMessageFactory,但结果是一样的。

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

有没有人可以解决这个问题?

【问题讨论】:

    标签: java soap spring-ws axiom


    【解决方案1】:

    真正的问题不在于 SaajSoapMessageFactory 或 AxiomSoapMessageFactory。应用程序试图在对 Web 服务的调用中发送 Base64 编码的图像字符串,并且在少数情况下这个编码的字符串太长(尽管整个消息的大小不足以保证 AxiomSoapMessageFactory)。

    当我们在 Web 服务配置 (WCF) 中将“Text”绑定替换为“Mtom”并在客户端代码中添加 marshaller.setMtomEnabled(true) 后,问题得到解决。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-22
      相关资源
      最近更新 更多