Skip to Content
Author's profile photo Former Member

Read the attachments of the input XI message in the message mapping

In my previous blog Read Multiple attachment content inside adapter module (Read Multiple attachment content inside adapter module) we saw about creating an adapter module which reads the attachments. Now in PI 7.1 we have an option to read the input attachments from the source message and create new output attachments or remove the attachment in Message Mapping itself. In this blog I would like to give you some information about the interfaces and methods present in PI 7.1 mapping API which helps to read the multiple attachments from the input source message. The interface “*Inputattachments*” in PI 7.1 mapping API contains methods to read the attachments of the XI message in the mapping. *Methods in inputattachments interface:*    1. areAttachmentsAvailable()      This method checks for the availability of attachments in the input message, it returns true, if the attachments can be accessed in the message mapping.      This depends on the settings of the operation mapping. Operation mapping in the Enterprise Service Repository has a flag to express whether the mapping wants to read the input attachments.    2. getAllContentIds()      The method getAllContentIds gets the content IDs of all input attachments of the source message. It is also possible to get the content IDs of the attachments, if the attachments themselves aren’t available for accessing.      It returns Collection of Strings with all content IDs of the attachments.    3. getAttachment()     getAttachment method takes the contentId as input parameter and returns the attachment content with the given contentId, provided there exists an attachment with this contentId.     It returns null if there is no such attachment. To get the attachment content we will be using the “*Attachment*” interface methods getContent(),getContentId(), getContentType () and getBase64EncodedContent(). These methods will return the attachment data provided that the “*Read Attachments*” flag has been checked in the operation mapping. Otherwise, this method will return null. *Creating an UDF to read the multiple attachments in message mapping:*While creating the Operation mapping make sure that you check the option ”*Read Attachments*”. Test the UDF code during runtime.


Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Daniel Graversen
      Daniel Graversen
      Hi Yugapreetha,
      I looked at the functionality but newer found a use case a case. It is nice to get the information without having to dig it out my self.

      /daniel Graversen

      Author's profile photo Shabarish Vijayakumar
      Shabarish Vijayakumar
      this should help lazy folks like me to avoid the research 🙂

      thanks for sharing !!!

      Author's profile photo Former Member
      Former Member
      Just found yours on the way of researching!!!
      Keep blogging!!!

      Author's profile photo Suraj S.R.
      Suraj S.R.

      The blog was having a informative piece of code which can be used for fetching the attachment from the payload.

      Also have a look at this Note 1255507 - Attachments not being sent to the receiver. It would be better to mention this in your blog.


      Author's profile photo Uday Suvvada
      Uday Suvvada

      Hi Yug,

      Can you please provide me the peice of code used to get the attachment from the sender,which was used in udf .as i am very much new to java.