Receive and Send and Email with the Oracle SOA Suite UMS Adapter

In this tutorial we will poll a Gmail account, then once an email comes in to the inbox we’ll add some text with BPEL and then send it through a different Gmail account with the UMS adapter provided by Oracle SOA Suite.

ums-proc0

Before we can start first you have to configure the UMS to work with Gmail in the SOA Infra, follow the instructions here.

These are the steps that we will follow to process an email through the UMS Adapter.

  1. Create a new Project in JDeveloper.
  2. Configure the UMS to Send an Email.
  3. Poll a Gmail Account.
  4. Add text to the message in BPEL.

 

1.- Create a new Project in JDeveloper.

Open JDeveloper and create a new generic application – call it SOA_Projects

ums-proc2

Follow the wizard and call your project UMSTest and don’t forget to select SOA as the default project technology

ums-proc3

 

At the end select an Empty Composite and you’re done.

 

2.- Configure the UMS to Send an Email.

Drag and drop an UMS Adapter to the External References section.

ums-proc4

Follow the wizard and set the following values:

Wizard Step Property Value
Service Name
Service Name EmailSender
UMS Adapter Connection
Connection JNDI Name Leave the default (eis/ums/UMSAdapterOutbound)
Operation
Operation type Outbound Send Notification
Operation Name SendNotification
Receive message ID as a reply unchecked
Outbound Notification Details
Type of notification Email
Subject Test Email
From outgoing@email.com
To some@email.com
Messages
Message is String type checked

 

3.- Poll a Gmail Account.

Drag and drop an UMS Adapter to the Exposed Services section.

ums-proc5

Follow the wizard and set the following values:

Wizard Step Property Value
Service Name
Service Name EmailReceiver
UMS Adapter Connection
Connection JNDI Name Leave the default (eis/ums/UMSAdapterInbound)
Operation
Operation Type Inbound: Receive Notification
Operation Name ReceiveNotification
Inbound Operation Details
Operation Mode Polling
Polling Frequency 5
Frequency Unit seconds
Inbound Thread Count 1
Inbound Notification Details
Type of Notification Email
Email Endpoint Configuration your_email@account
Messages
Message is String type checked

 

4.- Add text to the message in BPEL.

Drag and drop a BPEL Process Component to the Components section.

ums-proc6

Fill in the popup with the default Name and Namespace, select Asynchronous BPEL Process and uncheck Expose as a SOAP service, leave the Input and Output with the default variables.

ums-proc7

 

Connect the EmailReceiver Reference to BPELProcess1 Service in a different Service than the default.

ums-proc8

then connect BPELProcess1 Reference to EmailSender Service.

ums-proc9

Open BPELProcess1 and delete the Request and the Response Partner Links Connections.

ums-proc10

Then delete the BPELProcess1 Partner Link.

ums-proc11

Connect the receiveInput Activity to EmailReceiver Partner Link and when the Edit Receive Popup appears leave the default values.

ums-proc12

Connect the callbackClient Activity to EmailSender and leave the default values in the Edit Invoke Popup.

ums-proc13

Edit inputVariable and click in the magnifying glass of the Message Type, select Message Types > Partner Links > EmailReceiver > EmailReceiver.wsdl > Message Types > ReceiveNotification_msg in the Type Chooser Popup.

ums-proc14

And now edit outputVariable and click in the magnifying glass of the Message Type, select Message Types > Partner Links > EmailSender > EmailSender.wsdl > Message Types > SendNotification_msg in the Type Chooser Popup.

ums-proc15

Add a new variable and call it emailText

 

 

Then drag and drop an Assign Activity and call it payloadAssign.

ums-proc16

 

In the Assign Activity Popup right click in the Drag objects here section in the center and select Expression.

ums-proc17

Create an expression like this concat(bpws:getVariableData(‘inputVariable’,’body’,’/ns3:message/ns3:payload’), ‘ Some text added by BPEL’)  to add some text at the end of the message. Notice that if you want to extract, evaluate or add text n a different position you may want to use a

ums-proc18

Drag a line from the expression to Variables/Process/Variables/outputVariable/body/ns4:message/ns4:payload, with this you are assigning the Email’s body from the original email and the added text to the new email that the UMS Adapter is going to send. Click OK and you are ready to deploy.

ums-proc19

Deploy your application and send an email to your incoming email account, you will receive the same email in the outgoing account with the added text.
You can find the project in Github here.
Here is the jar file of the project

If you found this useful please drop me a comment.

4 comments: On Receive and Send and Email with the Oracle SOA Suite UMS Adapter

  • thank you for your helpful blog ,
    i had deployment your application but i get the error messages
    that sent by BPM
    Oracle Human Workflow Service

    The message you sent appears to be un-solicited. If you are responding to a notification, use the response link that was included with your notification.

    Error encountered while processing notification response :

    The NID string in response message appears to be corrupted/missing. Ensure that the NID string not modified and contains both beginning and ending ‘NID’.

    This message was automatically generated by Human Workflow Mailer. Do not reply to this mail.

    i need to know how can resolve this error .

  • Hello,

    I am getting the same issue “The NID string in response message appears to be corrupted/missing. Ensure that the NID string not modified and contains both beginning and ending ‘NID’”.

    How do you let the umsAdapter know that this is not an email that needs to be processed as return mail from a notification.

    Thanks
    JP

  • Marco, good post.

    We only see the attribute of payload which is the emailbody in the email, what if we want to manipulate the subject like based on something in the subject to further process them, or even store where the email was sent from. Where can we see these attributes ? Thanks

  • Oracle Human Workflow Service

    The message you sent did not appear to be in response to a notification. If you are responding to a notification, use the response link that was included with your notification.

    This message was automatically generated by Human Workflow Mailer. Do not reply to this mail.

    Any one knows why i am getting this mail from SOA ?????

Leave a reply:

Your email address will not be published.

Copyright © 2016 Marco Tello.