0

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

shurik2533
  • 1,770
  • 4
  • 22
  • 41

1 Answers1

1

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 
    }
}
shurik2533
  • 1,770
  • 4
  • 22
  • 41