我正在尝试使用下面的代码提取MTOM的内容
Iterator i = msg.getAttachments();
while (i.hasNext())
{
AttachmentPart att = (AttachmentPart)i.next();
Object obj = att.getContent();
}
其中msg
是SOAPMessage
的MIME类型,但rawContent是null
的名称,在获取AttachmentPart
时会崩溃
还有其他获取MTOM内容的方法吗?得到界限并循环通过?
答案 0 :(得分:0)
我结束了下面的代码
MimeMultipart mp = new MimeMultipart(new ByteArrayDataSource(InputStream, "multipart/related"));
int count = mp.getCount();
for (int i = 0; i < count; i++) {
BodyPart bodyPart = mp.getBodyPart(i);
String content = new String(read(bodyPart));
String partContentType = bodyPart.getContentType();
if(partContentType.toLowerCase().contains(SOAPConstants.SOAP_1_2_CONTENT_TYPE)) {
//process SOAP 1.2
}
if(partContentType.toLowerCase().contains(SOAPConstants.SOAP_1_1_CONTENT_TYPE)) {
//process SOAP 1.1
}
if(partContentType.toLowerCase().contains("application/octet-stream")) {
// process binary part
}
}