Showing posts with label UMS Adapter. Show all posts
Showing posts with label UMS Adapter. Show all posts

Monday, October 5, 2015

Forward (Email) the received Attachment via UMS Adapter

ForwardReceivedAttachment

Note : This post assumes that you already have some working knowledge of BPEL and XSLT functions and you're able to retrieve the content of Email attachment as described in my previous post - UMS Adapter - All about email attachments.

There may be cases when you have received an email attachment via UMS Adapter and you want to forward the same email as-is to another recipient e.g. if received attachment is invalid then forward to same to support team for further diagnosis. Following instructions show how you can achieve the same.

  • Drag and Drop another UMS Adapter (because the one you may have already was used to originally receive the Email) onto the right swimlane and select Outbound Send Notification in the Operation Type . Also check Receive Message Id as Reply . Click Next.
  • On the next screen choose Type of notification = Email and assign appropriate Subject and To Email ID. You can leave From as blank. Click Next.
  • Choose Message is of String type . Click Next and Finish.
  • Now drag and Drop an Invoke activity and connect to the UMS Adapter which will allow to create Input/Output variables e.g. InvokeSendErrorNotification_InputVariable and InvokeSendErrorNotification_OutputVariable
  • Now drag another Assign activity and place it just before the Invoke just created.
  • Assign relevant text for payload string to InvokeSendErrorNotification_InputVariable > body > message > payload . You can also use html formatted text if you wish in the payload.
  • Not navigate to InvokeSendErrorNotification_InputVariable > body > message > attachment > href and assign the incoming attachment href variable (ReceiveEmail_InputVariable). This variable was created as part of Receive activity when we configured previous UMS Adapter to receive the incoming email and attachment. Click OK and that's it.

The code for Assign activity is shown below for guidance.

  • First from expression - the payload that you want to appear as the email message. This is html formatted just to show how you can use html formatted tags.
  • InvokeSendErrorNotification_InputVariable.body/ns7:payload - Input variable created as new UMS Adapter. We're assigning into payload element of the same.
  • $ReceiveEmail_InputVariable.body/ns2:attachment[1]/@href - variable created from previous UMS Adapter to receve the attachment. [1] is used to refer to the first attachment in the email in case received email has multiple attachments.
  • $InvokeSendErrorNotification_InputVariable.body/ns7:attachment/@href - the variable created as part of new UMS Adapter. We're referring to the @href here which contains the reference to the attachment.

Happy Learning and let me know if any doubts!

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!