Old*_*mer 5 java mtom jax-ws jaxb eclipselink
我有一个使用基于模式的有效负载的jax-ws Web服务.添加MTOM附件类型:
<xs:element name="Attachment" type="xs:base64Binary"
xmime:expectedContentTypes="application/octet-stream"
minOccurs="0" maxOccurs="1" >
</xs:element>
Run Code Online (Sandbox Code Playgroud)
ws-import生成的java文件看起来正确:
@XmlRootElement(name = "Contact")
public class Contact {
@XmlElement(name = "Attachment")
@XmlMimeType("application/octet-stream")
protected DataHandler attachment;
Run Code Online (Sandbox Code Playgroud)
使用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://i.stack.imgur.com/BEbZS.jpg
Run Code Online (Sandbox Code Playgroud)
然后查看带有编码文件部分的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...
Run Code Online (Sandbox Code Playgroud)
但不断收到此错误:
[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>
Run Code Online (Sandbox Code Playgroud)
有什么建议?
错误消息基本上表明该值MjAxNi0wMS0wNVQwOTowMDowMA==是非法的。如果你检查一下,它是一个base64编码日期:
2016-01-05T09:00:00
Run Code Online (Sandbox Code Playgroud)
我不知道您正在尝试解组的对象中是否还有另一个字段。但万一解组过程无法处理 Base64 编码值。您应该检查某处是否需要适配器。
简而言之:您可能应该有一个 Base64 解码器或检查原始服务,因为解码后的数据String实际上并不是某种二进制数据。
(如果您插入所有使用的代码,我可以深入研究它。)
| 归档时间: |
|
| 查看次数: |
304 次 |
| 最近记录: |