我成功地使用了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消息,并且它始终有效。这是最近的错误。
在我的例子中,Web服务提供商将端点从https更改为http 此外,服务器端的 HTTPS 连接器也被禁用
在我的情况下,通过HTTP发送MTOM是父母引起的问题
解决方法是从我的 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发送它,问题解决了。