Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

OUTBOUND_MESSAGE_ATTACHMENTS not sent to server side  RSS feed

Adrian Barna
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can someone please tell me why the OUTBOUND_MESSAGE_ATTACHMENTS is not sent on server side?

When I'm trying (on server side) to get the attachments like:

Map<String, DataHandler> attachmentsMap = (Map<String, DataHandler>) msgContext.get(MessageContext.INBOUND_MESSAGE_ATTACHMENTS);
DataHandler dh = !attachmentsMap.values().isEmpty() ? attachmentsMap.values().iterator().next() : null;

dh is null.

but on client side just before sending the request if I do:

Map<String, DataHandler> attachmentsMap = (Map<String, DataHandler>) msgContext.get(MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS);
DataHandler dh = !attachmentsMap.values().isEmpty() ? attachmentsMap.values().iterator().next() : null;
InputStream in=dh.getInputStream();

the InputStream is populated just fine.

Please find below how I put the attachment in OUTBOUND:

Map<String, DataHandler> attachmentsMap = (Map<String, DataHandler>) context.get(MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS);
ByteArrayDataSource bads = new ByteArrayDataSource(file, PDF_MIME_TYPE);
DataHandler dh = new DataHandler(bads);

AttachmentPart attachmentPart = message.createAttachmentPart();
attachmentPart.setContent(new ByteArrayInputStream(file), PDF_MIME_TYPE);

attachmentsMap.put(fileId, dh);

Thank you in advance!
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!