SOAP连接重置

时间:2017-08-24 10:53:07

标签: web-services wcf soap soapui

我成功使用weimport maven工具针对客户端WSD生成了Jar文件,该文件由.net SOAP服务支持

当我从我的java客户端代码发出请求时,我收到以下日志

Accept: text/xml, multipart/related
Content-Type: multipart/related;start="<rootpart*dbea05e3-9997-4835-965c-02b1ed77e6b6@example.jaxws.sun.com>";type="application/xop+xml";boundary="uuid:dbea05e3-9997-4835-965c-02b1ed77e6b6";start-info="text/xml"
SOAPAction: "http://xxx/2013/xxx/RemotexxxService/UpdateProfile"
User-Agent: JAX-WS RI 2.2.10 svn-revision#919b322c92f13ad085a933e8dd6dd35d4947364b
--uuid:dbea05e3-9997-4835-965c-02b1ed77e6b6
Content-Id: <rootpart*dbea05e3-9997-4835-965c-02b1ed77e6b6@example.jaxws.sun.com>
Content-Type: application/xop+xml;charset=utf-8;type="text/xml"
Content-Transfer-Encoding: binary

我收到以下错误

javax.xml.ws.WebServiceException: java.net.SocketException: Connection reset
    at com.sun.xml.ws.transport.http.client.HttpClientTransport.readResponseCodeAndMessage(HttpClientTransport.java:210)
    at com.sun.xml.ws.transport.http.client.HttpTransportPipe.createResponsePacket(HttpTransportPipe.java:241)
    at com.sun.xml.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:232)
    at com.sun.xml.ws.transport.http.client.HttpTransportPipe.processRequest(HttpTransportPipe.java:145)
    at com.sun.xml.ws.transport.DeferredTransportPipe.processRequest(DeferredTransportPipe.java:110)
    at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:1136)
    at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:1050)
    at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:1019)
    at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:877)
    at com.sun.xml.ws.client.Stub.process(Stub.java:463)
    at com.sun.xml.ws.client.sei.SEIStub.doProcess(SEIStub.java:191)
    at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:108)
    at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:92)
    at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:161)

然而,当我复制整个SOAP消息并在SOAPUI中尝试它时,它确实有用..

我注意到SOAP UI生成了不同的http标头

POST http://coreservices-uat.legendonlineservices.co.uk/IRemoteContactUpdateService.svc HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
SOAPAction: "http://Infrastructure/2013/ContactPhoto/RemoteContactUpdateService/UpdateProfile"
Content-Length: 1761
Host: coreservices-uat.legendonlineservices.co.uk
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)

我无法想象Java版本或Apache-Httpclient或Jasws实现之间的区别会有什么不同

可能是内容类型吗?我的意思是在SOAP UI中,内容类型是 与Java客户端不同

可能是导致问题的wsdl中的以下定义吗?

<wsp:Policy wsu:Id="BasicHttpBinding_RemoteContactUpdateService_policy">
<wsp:ExactlyOne>
<wsp:All>
<wsoma:OptimizedMimeSerialization xmlns:wsoma="http://schemas.xmlsoap.org/ws/2004/09/policy/optimizedmimeserialization"/>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>

注意:我几天前使用相同的Java代码向服务器发送相同的XML消息,它总是有效....这是最近的错误。

1 个答案:

答案 0 :(得分:1)

就我而言,Web服务提供商将端点从https更改为http 还禁用了服务器端的https连接器

在我的情况下发送MTOM over http显然导致问题

修复是从我的JAXWS客户端禁用MTOM

Binding binding = bp.getBinding();
SOAPBinding sb = (SOAPBinding)binding;
sb.setMTOMEnabled(false);

此后,客户端请求的内容类型从

更改
Content-Type: multipart/related;start="<rootpart*dbea05e3-9997-4835-965c-02b1ed77e6b6@example.jaxws.sun.com>";type="application/xop+xml";boundary="uuid:dbea05e3-9997-4835-965c-02b1ed77e6b6";start-info="text/xml"
Content-Type: application/xop+xml;charset=utf-8;type="text/xml"

Content-Type: text/xml;charset=UTF-8
然后我通过http发送它,问题解决了。