我有一个使用基于架构的有效负载的jax-ws web服务。添加MTOM附件类型:
<xs:element name="Attachment" type="xs:base64Binary"
xmime:expectedContentTypes="application/octet-stream"
minOccurs="0" maxOccurs="1" >
</xs:element>
ws-import生成的Java文件看起来是正确的:
@XmlRootElement(name = "Contact")
public class Contact {
@XmlElement(name = "Attachment")
@XmlMimeType("application/octet-stream")
protected DataHandler attachment;
使用soapUI发送请求。
HTTP 头部:
Accept-Encoding: gzip,deflate
Content-Type: multipart/related; type=application/xop+xml; start=<rootpart@soapui.org>; start-info=text/xml; boundary=----=_Part_96_20541990.1485816424570
SOAPAction: http://hsn.us.banner.hsntech.com/Level1Request
MIME-Version: 1.0
Content-Length: 47624
[1]: https://istack.dev59.com/BEbZS.webp
然后请看编码文件部分的HTTP部分:
------=_Part_96_20541990.1485816424570"
Content-Transfer-Encoding: binary"
Content-ID: <test1.jpg>"
Content-Disposition: attachment; name="test1.jpg"; filename="test1.jpg""
[0xff][0xd8][0xff][0xe0][0x0][0x10]JFIF[0x0][0x1][0x1][0x1][0x0]`[0x0]`[0x0][0x0][0xff][0xdb][0x0]C[0x0][\n]"... etc...
但是一直出现这个错误:
[Exception [EclipseLink-25004] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.XMLMarshalException
Exception Description: An error occurred unmarshalling the document
Internal Exception: java.lang.IllegalArgumentException: MjAxNi0wMS0wNVQwOTowMDowMA==]</faultstring></ns0:Fault></S:Body></S:Envelope>
有什么建议吗?