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

时间:2017-01-25 23:15:52

标签: web-services soap jax-ws soapui mtom

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

    <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中的附件: enter image description here 当我从日志中查看http:

http标题:

 "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主体中的

,请参阅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]

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

1 个答案:

答案 0 :(得分:1)

检查请求属性中启用MTOM 是否设置为 True

Request Properties