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.
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.
- Create a new Project in JDeveloper.
- Configure the UMS to Send an Email.
- Poll a Gmail Account.
- 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
Follow the wizard and call your project UMSTest and don’t forget to select SOA as the default project technology
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.
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 | ||
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.
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 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.
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.
Connect the EmailReceiver Reference to BPELProcess1 Service in a different Service than the default.
then connect BPELProcess1 Reference to EmailSender Service.
Open BPELProcess1 and delete the Request and the Response Partner Links Connections.
Then delete the BPELProcess1 Partner Link.
Connect the receiveInput Activity to EmailReceiver Partner Link and when the Edit Receive Popup appears leave the default values.
Connect the callbackClient Activity to EmailSender and leave the default values in the Edit Invoke Popup.
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.
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.
Add a new variable and call it emailText
Then drag and drop an Assign Activity and call it payloadAssign.
In the Assign Activity Popup right click in the Drag objects here section in the center and select Expression.
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
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.
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.
6 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 ?????
Thanks Marco. Its a great help and learning. its working fine for me. a big thumbs up.
xabf57