我正在尝试使用以下代码提取MTOM的内容
Iterator i = msg.getAttachments();
while (i.hasNext())
{
AttachmentPart att = (AttachmentPart)i.next();
Object obj = att.getContent();
}其中,msg是SOAPMessage MIME类型,但rawContent作为null提供,并将在获取AttachmentPart时崩溃
有没有其他方法来获取MTOM内容?获取边界并循环通过?
发布于 2018-12-19 22:22:01
我最终得到了下面的代码
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
}
}https://stackoverflow.com/questions/53785130
复制相似问题