Wednesday, September 2, 2015

UMS Adapter - All about email attachments

untitled1

SOA Suite - 11.1.7.6

A lot has already been written at this blog about how to configure UMS Adapter and read attachments from it. Hence this post is just to describe additional points to read/process the attachments. The post assumes that you're able to receive the incoming email using UMS Adapter successfully and able to get the BPEL process instantiated.

How to Read/Fetch the Attachment?

BPEL 1.1 - It's fairly simple in BPEL 1.1 using the following syntax in the Assign Activity.

  • Receive1_ReceiveNotification_InputVariable - is the variable created out of Receive Activity connected to Inbound UMS Adapter
  • Body, ns2:message/ns2:attachment - are the variable part and element inside the variable respectively created by default.
  • ns2:/attachment [1] is used to read the first attachment always. You may want to loop through all the attachments and choose the one you desire based on Content-Type or Attachment Name or etc. Read my another post on how to retrieve the attachment names from the Email attachments.
  • CustomAttachmentVariable - is the custom Element type variable of Attachment Message with the namespace {http://platform.integration.oracle/blocks/adapter/fw/metadata/ReadEmailAttachment}message. I created this variable simply to complete the Assign. You may further access this variable for extracting the contents of the attachment or writing to file etc.

BPEL 2.0 - It's not a rocket science here as well, just one thing to note is that default BPEL 2.0 variable format ($Receive1_ReceiveNotification_InputVariable.body/ns2:attachment) (note the . between InputVariable.body ) is not supported by the ora:getAttachmentContent() function. So you have to explicitly write the variable in the BPEL 1.1 format. You can assign intially from the Design View and then go into BPEL source and modify the default Assign code generated to below: (ora:getAttachmentContent('Receive1_ReceiveNotification_InputVariable' , 'body','/ns2:message/ns2:attachment[1]')) - note the body part.

 

What to do with the Attachment read?

There are basically 3 things that you may want to do with the attachment just read. To keep this post concise, they have been put into separate posts.

Please feel free to navigate through and let me know if any doubts! Happy Emailing!

5 comments:

  1. Neeraj, good post. Question: How do you get the message type for CustomAttachmentVariable?

    ReplyDelete
  2. Neeraj, never mind, got it, the getAttachmentContent is of base64binary type so for example can be mapped to fileContent element of primaryFile with UCM web service universalCheckIn.

    ReplyDelete
  3. Neeraj, never mind, got it, the getAttachmentContent is of base64binary type so for example can be mapped to fileContent element of primaryFile with UCM web service universalCheckIn.

    ReplyDelete
  4. Hi Neeraj,

    I have a requirement where i will get the pdf as an attachment and i need to translate it to xml.Dou have any idea on how to do that?

    ReplyDelete
  5. Great Help, Thank you.

    ReplyDelete