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.

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

Leave a reply:

Your email address will not be published.

Copyright © 2016 Marco Tello.