Developing and deploying Java Embedding activity in BPEL 2.0 in SOA Suite 11g calling a custom Java Class that has dependencies on 3rd party librariesJava Embedded activity can call a custom Java class that relies on 3rd party Java libraries. This means that a lot of existing functionality from the Java open source community is at the disposal of the BPEL developer. This article shows a simple example of developing and deploying a BPEL process that uses Java Embedded Activity that calls a custom Java Class that uses Apache HttpClient to make Http POST calls. The article demonstrates how to develop the BPEL process, the Java Embedded activity, Java Class and how to deploy the SOA Composite application. It also presents the results of running the composite application.
Steps for a simple, straightforward demonstration:
1. Create SOA Composite application in JDeveloper 11g – based on the BPEL template
2. Create the directory Application_Root\project\SCA-INF\lib
3. Copy 3rd party libraries to the directory created in the previous step
4. Create the custom Java Class – in the SCA-INF\src directory
The code of this Java Class is the following – inspired by a previous blog article: http://technology.amis.nl/blog/15098/create-simple-java-application-to-post-json-message-to-cometd-bayeux-channel-using-apache-httpclient-and-maven-style-netbeans-project.
6. Create the Java Embedding activity in the BPEL process
7. (optionally rename the activity) and Double click the activity to start editing the Java snippet
9. Deploy the SOA Composite applications.
Note: all Java classes in SCA-INF/src and all JAR files in SCA-INF/lib are included in the SAR:
10. Test-run the BPEL process through its Web Service interface
The Java snippet reads an input variable, writes some logging to the console, passes the value of the input variable to the custom Java class that performs an HTTP POST request (handled by an extremely simple Servlet that does nothing but write the request contents to the console and return a standard response). This response is put on the outputVariable by the Java snippet.
When making this call to the BPEL process:
This output is found in the SOA Suite console:
And the output from the Servlet is
Finally the response from the BPEL process – including the response from servlet invoked by the Java snippet: