0

How do I retrieve SOAP attachments? I am doing something like the following:

Iterator<AttachmentPart> i = soapMessage.getAttachments();
while(i.hasNext())
{
    AttachmentPart obj = i.next();
    InputStream rawContent = obj.getRawContent();
}

The raw content returns something like:

------=_Part_2980_1570690085.1342564119748

content-type: image/png; Name=IMG_0583.png

content-transfer-encoding: BASE64

content-disposition: Attachment; Filename=IMG_0583.png

content-id: 1

content-location: IMG_0583.png

content-length: 11210

iVBORw0KGgoAAAANSUhEUgAAARMAAABfCAMAAAD8mtMpAAAC/VBMVEUBIrIZH6qfBSGwAyWSDiTE Aym9DifSCyysGCiQISvJES3eDDLMFinYGDDdFyzkGjbmGzGhMTePNjwsSa3JKDQYTukOZh3iKDKK

------=_Part_2980_1570690085.1342564119748--

How do I retrieve the part I highlighted in bold above?

Mac
  • 14,615
  • 9
  • 62
  • 80
serverfaces
  • 1,155
  • 4
  • 22
  • 49

1 Answers1

0

I think you want to use the getContent method and not the raw:

obj.getContent();

or the getBase64Content method also as the encoding is base64

pna
  • 5,651
  • 3
  • 22
  • 37
  • The issue I have is that calling getBase64Content() returns the Base64 encoded value of the raw content whereas the image is already Base64 encoded which is present in the raw content as highlighted above. – serverfaces Jul 18 '12 at 00:10
  • Let's say the original image is A, and raw content is B. B has the Base64 encoded version of A in it. Calling getBase64Content() returns C which is the Base64 encoded version of B. I don't want C, what I want is just B1 within B. Let me try obj.getContent() as well. – serverfaces Jul 18 '12 at 00:12
  • Also I tried obj.getContent() which returned an instance of: javax.mail.internet.MimeMultipart – serverfaces Jul 18 '12 at 00:41
  • then you are done: look at this http://stackoverflow.com/questions/1748183/download-attachments-using-java-mail – pna Jul 18 '12 at 00:55