How can I parse attachment part, which type is multipart/related in SAAJ (SOAP Messages with Attachments)?

StackOverflow https://stackoverflow.com/questions/20799487

  •  21-09-2022
  •  | 
  •  

سؤال

I receive an SAAJ message with SOAP with Attachments API for Java, that contain multipart/related attachment. One part of this attachment is multipart/related too. That is I have AttachmentPart with multipart/related content. Is there a standard way to parse it?

In particular, I need to parse MMS(MM7)-message

enter image description here

هل كانت مفيدة؟

المحلول

Solved

All I need is cast AttachmentPart.getContent()'s result to MimeMultipart

MimeMultipart mp = (MimeMultipart) attachment.getContent();
for (int i = 0; i < mp.getCount(); i++) {
    Part bp = mp.getBodyPart(i);
    if (bp.isMimeType("text/*")) {
        String text = (String)bp.getContent();
        //process text
    } else if (bp.isMimeType("image/*")) {
        InputStream is = bp.getInputStream();
        //process image 
    }
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top