我正在从 SOAP 消息中获取附件并在我的应用程序中使用它们。
我不会从原始邮件中删除附件。之后,我尝试使用以下代码将包含附件(SwA)的原始 SOAPMessage转换为字符串:
ByteArrayOutputStream stream = new ByteArrayOutputStream();
soapMsg.writeTo(stream);
String message = new String(stream.toByteArray(), "utf-8");
它抛出以下异常:
com.sun.xml.internal.messaging.saaj.soap.MessageImpl writeTo
SEVERE: SAAJ0540: Error during saving a multipart message
com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Error during saving a multipart message
at com.sun.xml.internal.messaging.saaj.soap.MessageImpl.writeTo(MessageImpl.java:1233)
at main.SOAPMTOMUtilityTest.main(SOAPMTOMUtilityTest.java:161)
Caused by: com.sun.xml.internal.messaging.saaj.packaging.mime.MessagingException: no content
at com.sun.xml.internal.messaging.saaj.packaging.mime.internet.MimeBodyPart.writeTo(MimeBodyPart.java:905)
at com.sun.xml.internal.messaging.saaj.packaging.mime.internet.MimeMultipart.writeTo(MimeMultipart.java:266)
at com.sun.xml.internal.messaging.saaj.soap.MessageImpl.writeTo(MessageImpl.java:1224)
... 1 more
CAUSE:
com.sun.xml.internal.messaging.saaj.packaging.mime.MessagingException: no content
at com.sun.xml.internal.messaging.saaj.packaging.mime.internet.MimeBodyPart.writeTo(MimeBodyPart.java:905)
at com.sun.xml.internal.messaging.saaj.packaging.mime.internet.MimeMultipart.writeTo(MimeMultipart.java:266)
at com.sun.xml.internal.messaging.saaj.soap.MessageImpl.writeTo(MessageImpl.java:1224)
at main.SOAPMTOMUtilityTest.main(SOAPMTOMUtilityTest.java:161)
有人知道吗?
_谢谢,布山