在Liberty Content-Type中防止SOAP响应:multipart / related

时间:2017-09-28 12:44:40

标签: web-services java-ee soap websphere websphere-liberty

我们当前正在WAS8上运行一个应用程序。现在我们将此应用程序迁移到Liberty。目前我们遇到的问题是此应用程序的SOAP响应是内容类型multipart/related。看起来像那样:

HTTP/1.1 200 OK
X-Powered-By: Servlet/3.1
Content-Type: multipart/related; type="application/soap+xml"; boundary="uuid:acacdbe0-a9a8-46cc-aedf-58570a630ff7"; start="<root.message@cxf.apache.org>"; start-info="application/soap+xml"
Content-Language: en-DE
Content-Length: 670
Date: Thu, 28 Sep 2017 12:00:16 GMT


--uuid:acacdbe0-a9a8-46cc-aedf-58570a630ff7
Content-Type: text/xml; charset=UTF-8; type="application/soap+xml";
Content-Transfer-Encoding: binary
Content-ID: <root.message@cxf.apache.org>

<soap:Envelope>....</soap:Envelope>
--uuid:acacdbe0-a9a8-46cc-aedf-58570a630ff7--

这对我们不利,因为其他客户可能会遇到解析问题。

使用WAS8时,响应的内容类型为application/soap+xml;charset=UTF-8;action="mySoapResponse",而且没有uuid和内容。

Here我发现了类似于我的问题,但并不完全。我们也定义了SOAPBinding,但作为我@WebService的注释看起来像这样: @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)@BindingType(value = javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING)

要使应用程序在Liberty上运行,我们必须将部署描述符( web.xml )从版本 2.4 更新为 3.0 。我想这也改变了应用程序的行为。

主要原因是因为SOAPBinding注释还是其他原因?

更新: 以下是WAS8应用程序服务器的响应:

HTTP/1.1 200 OK
Date: Wed, 04 Oct 2017 06:24:22 GMT
Cache-Control: private
Cache-Control: max-age=10
X-Frame-Options: SAMEORIGIN
X-Powered-By: Servlet/3.0
Content-Length: 403
Keep-Alive: timeout=20
Connection: Keep-Alive
Content-Type: application/soap+xml; charset=UTF-8; action="mySoapResponse"
Content-Language: en-US

<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope ...>...</soapenv:Envelope>

UPDATE2:

我注意到Liberty SOAP响应也获得了不在WAS8响应中的<env:header>

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
    <env:Header xmlns:env="http://www.w3.org/2003/05/soap-envelope"/>
    <soap:Body>...

所以似乎背景中正在发生一些事情。我查看了WSDL,但没有定义标题,也没有 multipart 。 如何追溯步骤并查看此设置对我的回复的位置?

2 个答案:

答案 0 :(得分:0)

也许Liberty正在自动使用MTOM。如果您在SOAP信封中看到<xop:Include..,则可能是MTOM。您可以通过向WebService @MTOM(enabled="false")

添加注释来关闭它

答案 1 :(得分:0)

根据IBM支持, CXF (Liberty)的这种行为归因于我的 JAXB类中的注释@XmlAttachmentRef。删除它将导致非多部分响应。不幸的是,当我这样做时,发送的附件将无法正确处理,并且MIME类型将丢失。

目前我们有IBM支持调查这个,如果这可以在 CXF (Liberty)中以某种方式修复,因为在 Axis2 (tWAS8.0)中它表现不同。我会尽力保持更新。