0
我具有低於MTOM響應作爲字符串手動解析MTOM消息
--uuid:6b6fab3b-c481-4648-9eb5-8690096eb54d
Content-Type: application/xop+xml; charset=UTF-8; type="application/soap+xml";
Content-Transfer-Encoding: binary
Content-ID: <[email protected]>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"><soap:Body><ns2:receiveDocumentFileResponse xmlns:ns2="http://webservice.edefter.gib.gov.tr/"><return><fileName>GIB-XXXX-201512-KB-000000.zip</fileName><binaryData><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:[email protected]"/></binaryData></return></ns2:receiveDocumentFileResponse></soap:Body></soap:Envelope>
--uuid:6b6fab3b-c481-4648-9eb5-8690096eb54d
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary
Content-ID: <[email protected]>
Content-Disposition: attachment;name="GIB-XXXX-201512-KB-000000.zip"
/***********MTOM Content****************/
--uuid:6b6fab3b-c481-4648-9eb5-8690096eb54d--
我使用CXF單元測試代碼來解析上述內容關於到xop/mtom parse
附件總是空和執行itr.next(當);行,我得到異常java.lang.IndexOutOfBoundsException:指數:0,大小:0
InputStream is = null;
InputStream attIs = null;
try {
org.apache.cxf.message.Message cxfMessage = new MessageImpl();
is = new ByteArrayInputStream(response.getBytes("UTF-8"));
// FileInputStream fis = new FileInputStream(new File(
// "D:/wss/gibreturn.txt"));
// String ct = "multipart/related; type=\"application/xop+xml\"; "
// + "start=\"<[email protected]>\"; "
// + "start-info=\"text/xml; charset=utf-8\"; "
// + "boundary=\"----=_Part_4_701508.1145579811786\"";
cxfMessage.setContent(InputStream.class, is);
cxfMessage.put(org.apache.cxf.message.Message.CONTENT_TYPE,
"application/xop+xml; charset=UTF-8; type=\"application/soap+xml\";");
AttachmentDeserializer deserializer = new AttachmentDeserializer(
cxfMessage);
deserializer.initializeAttachments();
InputStream attBody = cxfMessage.getContent(InputStream.class);
System.out.println(deserializer.toString());
Collection<org.apache.cxf.message.Attachment> atts = cxfMessage
.getAttachments();
Iterator<org.apache.cxf.message.Attachment> itr = atts.iterator();
org.apache.cxf.message.Attachment a = itr.next();
attIs = a.getDataHandler().getInputStream();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (is != null) {
try {
is.close();
} catch (Exception e) {
}
}
if (attIs != null) {
try {
is.close();
} catch (Exception e) {
}
}
}
謝謝 親切的問候
具體的問題可能幫助:你想要發生什麼? –
@ Y.B。在mtom消息中有附件,我期望AttachmentDeserializer應該處理附件 –