EJB session beans can be invoked from a BPEL process through WSIF. Oracle BPEL PM ships with a WSIF provider for invoking EJBs.
For demonstrating this, lets create a new EJB session bean. The session bean shall have one single business method namely "greetUser" that takes in a string argument userName, and returns a string value "Hello <USERNAME>".
Step 1: Creating the HelloWorld Session Bean.
- Create a new BPEL empty process project.
- Open up the New Gallery and choose to create a new EJB session bean.
- Choose the option for creating EJB 2.1 session bean. Give the Bean the name"HelloWorld", accept the remaining defaults and finish the wizard.
- Double click on the EJB in the Applications Navigator to bring up the EJB Module Editor". Specify the new business method in the "Methods" tab. Type in the parameter name and type manually in the text editor
- CLick ok to accept the changes. Click on the "orion-ejb-jar.xml" in the Applications Navigator. Here you need to provide the JNDI locaiton of the session bean. For this, add a "location" attribute on the <SESSION-DEPLOYMENT>to provide the JNDI "ejb/session/HelloWorld".
- Your bean is now ready for deployment. Build the project and deploy to an OC4J container.
Step 2: Build the BPEL Process
- Create a new BPEL Process project.
- Create a new WSDL document in the project directory and name it HelloWorldEJB.wsdl.
- Add the bindings section that allow the process to invoke the EJB through WSIF. The salient portion of the bindings section is the jndiProviderURL. For an Application Server install, use the opmn ormi jndi provider URL. For standalone installations,use plain ormi provider URLs. The ejbName in the provider URL is the ejbName value in the ejb-jar.xml that was created as a part of the EJB session bean creation.
- Create a partnerlink for the WSDL that you just created and an invoke activity that can be used to invoke the plnk.
- Provide the username/password for connecting to the OC4J Instance that hosts the EJB within the bpel.xml deployment descriptor. This is typically the oc4jadmin user.
<?xml version = '1.0' encoding = 'UTF-8'?>
<BPELSuitcase>
<BPELProcess id="HelloWorldBPELClient" src="HelloWorldBPELClient.bpel">
<partnerLinkBindings>
<partnerLinkBinding name="client">
<property name="wsdlLocation">HelloWorldBPELClient.wsdl</property>
</partnerLinkBinding>
<partnerLinkBinding name="HelloWorld_plt">
<property name="wsdlLocation">HelloWorldEJB.wsdl</property>
<property name="java.naming.security.principal">oc4jadmin</property>
<property name="java.naming.security.credentials">welcome1</property>
</partnerLinkBinding>
</partnerLinkBindings>
</BPELProcess>
</BPELSuitcase>- Copy the EJB compiled classes from the EJB project created earlier into the $ORACLE_HOME/bpel/system/classes directory and restart the BPEL runtime. These classes are required for BPEL to get a hold on the home interface of the EJB to create an invoke the business method.
- Deploy the BPEL Process and see the results for yourself
The demo EJB and BPEL Client project can be downloaded from this link.
Comments (5)
Great job but screenshots seem to be screwed a bit.
Did you try the same for Oracle ESB as well.
Posted by Rakesh | May 16, 2008 7:09 PM
Posted on May 16, 2008 19:09
If you choose EJB 3.0 and not 2.1, you don't have to edit the WSDL manually. You simply add a WSIF annotation to the service interface... It works pretty well.
Posted by Ronen | May 17, 2008 1:58 PM
Posted on May 17, 2008 13:58
thanks for the comment Ronen.
Posted by Ramkumar Menon | May 17, 2008 4:59 PM
Posted on May 17, 2008 16:59
What If both BPEL Process and EJB are deployed on different server ?
Posted by Anonymous | November 21, 2008 11:20 AM
Posted on November 21, 2008 11:20
Hi Menon,
I am having a java class where i used PrintWriter object to write into a file.Its working fine(it creates a file and writes into that)
But, the same jave class i loaded into oracle and i have given the server output path for the creating the file its not working.
Can anyone reply me asap.
Posted by Stanley | February 2, 2009 4:53 AM
Posted on February 2, 2009 04:53