MTOM 附件在 SOAP 负载中编码两次

MTOM attachment encoded twice in SOAP payload

我确定这只是飞行员错误,但找不到解决方案。有一个 jax-ws Web 服务,其中包含一个包含附件的 soap 负载操作。这是架构文档的片段。这是定义的类型:

    <xs:complexType name="BinaryAttachmentType">
           <xs:simpleContent>
              <xs:restriction base="xmime:base64Binary">
                <xs:attribute ref="xmime:contentType" use="required" />
              </xs:restriction>
            </xs:simpleContent>
    </xs:complexType>

嵌入此元素定义中:

<xs:element name="Contact">
    <xs:complexType>
        <xs:sequence>
            <!-- removed other elements -->
           <xs:element name="Attachment" type="BinaryAttachmentType" minOccurs="0" maxOccurs="1"/>
        </xs:sequence>
    </xs:complexType>
</xs:element

使用 soapUI,SOAP 看起来像:

<hsn:Contact>
    <!-- other elements -->
        <hsn:Attachment xm:contentType="image/jpeg">cid:323665198529</hsn:Attachment>
</hsn:Contact>

soapUI 中的附加文件: 当我从日志中查看 http 时:

http Header:

 "Content-Type: multipart/related; type="text/xml"; start="<rootpart@soapui.org>"; boundary="----=_Part_15_23791896.1485382707426""
 "SOAPAction: "http://hsn.us.banner.hsntech.com/Level1Request""
 "MIME-Version: 1.0"
 "Content-Length: 104164"
 "Host: localhost:7001"
 "User-Agent: Apache-HttpClient/4.1.1 (java 1.5)"
 "------=_Part_15_23791896.1485382707426"
 "Content-Type: text/xml; charset=UTF-8"
 "Content-Transfer-Encoding: 8bit"
 "Content-ID: <rootpart@soapui.org>"

在 SOAP body 中,请参阅带有 base64 编码文件的附件元素:

<hsn:AttachmentFileName>test1.jpg</hsn:AttachmentFileName>
        <hsn:Attachment xm:contentType="image/jpeg">/9j/4AAQSkZJRgABAQEAYABgAAD .. rest of base64 encoding

然后在 SOAP 消息之后,再次编码附件:

------=_Part_15_23791896.1485382707426
  Content-Type: image/jpeg; 
  name=Foo.jpg
  Content-Transfer-Encoding: binary
  Content-ID: <Foo.jpg>
  Content-Disposition: attachment; name=Foo.jpg; filename=Foo.jpg

  (... encoded attachment again )
 [0xff][0xd8][0xff][0xe0][0x0][0x10]JFIF[0x0][0x1][0x1][0x1][0x0]`[0x0]`[0x0][0x0][0xff][0xdb][0x0]C[0x0][\n]

那么,为什么文件在请求中编码了两次?谢谢。

检查 Enable MTOM 在 Request Properties 中是否设置为 True: