Oracle SOA Suite Online Training

Interested in learning Oracle SOA Suite 12c?
Learn from the author of this blog!
A complete and comprehensive course on the #1 platform on SOA - Oracle SOA Suite

Click here to find the complete course details
Click here to check the first session on Oracle SOA Suite 12c


Configuring Email Notification in Oracle SOA Suite 11g

Oracle SOA Suite 11g provides User Message Service(UMS) that enables users to send notifications via various channels like Email, SMS, IM, Voice Mail.

Each of these channels need to be configured first before they can be used.

This post explains you how to use Email channel as the notification service in Oracle SOA Suite 11g.

Once configured, it can be used in the Human Tasks as well as with the Oracle BPEL Extension "Email" activity.

Before anything, I'll just introduce you to the protocols used in EMAIL communication
Sending a Mail
SMTP : protocol to send mail to a mail server

Retrieving a Mail
POP3 : Downloads the mail from the mail server in to a local machine. This will be helpful if you have only one machine in which you'll always check your emails.
IMAP : Doesn't actually download the email to the local server(you can always do it if required). It helps you sync up your mail across machines, and gives the capability of having hierarchical maintenance of your emails ie, you can maintain a folder structure for specific mails. You create a folder in one machine, drag some msg's into it, that will be automatically synced up when you chk your mails from another machine as the changes are not done in your local machine, but the server.  Also, when your INBOX is too huge, it will just retrieve headers to your mail client, only when you click on it, it will actually download the message to show you the details. This makes the performance better than POP3.

For using EMAIL notification service, you may not have your own email servers. You can always use a freely available mail like gmail.

This example shows you how to use gmail as the mail server for Email Notifications.

Configuring Email notification service involves 4 steps(first step can be ignored if your mail server doesn't need SSL)

Step 1 : Import certificates from gmail and add it to your server trust store
Step 2 : Configure email driver properties
Step 3 : Enable notification mode
Step 4 : Testing the configuration

Below procedure lists a step-by-step approach of setting up gmail server as the default mail server for your UMS

Step 1 : Import certificates from gmail and add it to your server trust store
Any email server uses two protocols to send/receive messages.
SMTP for sending mails
Either POP3 or IMAP for receiving mails. Gmail uses IMAP for retrieving mails.
So, you need to get both SMTP and IMAP certificates connecting to the gmail server inorder to send/receive mails to/from your inbox.

You can download the certificates using an opensource software called openssl. First, you need to download and install it.
Downloading SMTP certificate
Open command prompt and cd to openssl_install_folder/bin
Give the below command to view the smtp certificate
openssl s_client -connect
Copy the code highlighted in the picture above and paste it to a file and name it smtp_gmail.cert

Similarly, issue the follwing command to view the IMAP certificate
openssl s_client -connect

Copy the code highlighted in the picture above and paste it to a file and name it imap_gmail.cert

Now that you have both smtp and imap certificates with you, you need to import these to your server trust store
For this, open command prompt and navigate to %JAVA_HOME%/bin
Issue the following command
keytool -import -alias gmail-smtp -keystore gmail-keystore.jks -<location of smtp_gmail.txt>
It asks for password, give a password and pls remember it  as we'll use it later.
Issue a similar command for importing imap certificate
keytool -import -alias gmail-imap -keystore gmail-keystore.jks -<location of imap_gmail.txt>

If the above commands dont work, issue the below ones. Note : do this only if the above commands dont work
keytool -import -alias -keystore trusted-certificates.jks -file <location of smtp_gmail.txt>
 keytool -import -alias -keystore trusted-certificates.jks -file
<location of imap_gmail.txt>
Once you are done with importing the trust certificates to the keystore using the keytool, you need to tell the managed server(soa_server1) that there is a user defined trust store from which it has to look for keystore
This will be done by editing the %MIDDLEWARE_HOME%\user_projects\domains\soa_domain\bin\setDomainEnv.cmd file
Search for and replace the value with the the gmail-keystore.jks file path that was generated by the keytool command. Also you need to edit not avl, create one). So finally your entries should look somewhat similar to this\oracle\Middleware\jdk160_29\bin\demogmailcertstore.jks

Once you are done with this edit, one step is pending, where you will tell the managed server that a custom keystore is setup and has to be considered.
This is done by opening the Admin Console(<adminHost>:<adminPort>/console --> Environments --> Servers --> click on soa_server1)

Click on Keystores, and change the Keystores to "Custom Identity and Java Standard Trust"

That's it. You're done with configuring the certificates!!!

Step 2 : Configure email driver properties
This step configures email driver properties like email server details, incoming/outgoing email, passwords, etc.

For this, open EM, traverse as shown to open Email Driver Properties Screen

Configure the below mentioned properties
As mentioned, SMTP is used to send mails
This is the port gmail uses for SMTP

The default FROM address (if one is not provided in the outgoing message).

Password of the gmail id
Option to be selected is "Use Cleartext Password"
---------similarly for----
As mentioned, IMAP is used to receive mails
This is the port gmail uses for IMAP

No need to check this option




You're done!!!

Step 3 : Enable notification mode
This step lets the server know what mode to use for notifications. Since that we've configured email notification above, we'll enable EMAIL notification mode
Traverse to WorkFlow Config in EM as shown in picture

Setup the required values

Restart the Admin(for step1) & Managed Server(for steps 2&3)
This sets up the required configurations.

Step 4 : Testing the configuration
The last thing that you need to do is test it.

Navigate to Human WorkFlow as  shown

Notification Management --> Send Test Notification --> give detials in the popup and chk the mail
Hope this helps you in working with EMAIL notification service.

Thanks for going through my post, feel free to provide a feedback!

Error: Global element declaration/definition of name are duplicated at the following locations

Sometimes, your composite suddenly stopped working after you've started referring to a new xsd file - via a service/reference/component.

Your composite was getting deployed properly, and suddenly after few changes, it gets the following error

Error: Global element declaration/definition of name '{}part1' are duplicated at the following locations:


Error(80): query "/ns2:part1/ns2:firstName" is invalid, because Global element declaration/definition of 
name '{}part1' are duplicated at the following locations:

Sometimes, you get this error when your composite is working with more than one schema(xsd) files.

Reason for this is that if both the partname and the namespace are exactly same, then their definitions also have to be exactly same.

A simple scenario would be, if you are using one xsd in your composite and there is an other xsd being referred by one of the components/services/references in your composite. And lets say that both the xsd's have the same part name. In such cases, both the parts have to be exaclty same, even annotations in that part.

For example, in this composite, this is the xsd being used
And lets say one of the references/services in the composite is either using/referring to an xsd as below

If you observe these two schemas, and the corresponding source,
Both are having the same namespace as well as the part names(part1 in this case). But second xsd is having a different annotation
Thumb rule is that when the namespaces are the same and the part names are same, then the definitions for those parts across the xsd's should be exacly same.

Resolution to this is that, if you change the annotation of second xsd from "A sample element1" to "A sample element", the issue gets resolved.

 Hope this helps you. Cheers.