Tuesday, 29 June 2010

ServiceMix (FUSE ESB) and WS-BPEL processes

Share
Today's post is a continuation of my ServiceMix 4 series. Today I will show you how to integrate ServiceMix (FUSE ESB) with Apache ODE. I will show you how to expose Process and Instance Management API Web Services. Also, I will build an example JBI WS-BPEL process and deploy it to FUSE ESB.

Installation on ServiceMix and FUSE ESB

FUSE ESB comes with Apache ODE installed already. All you have to do is install ode feature:

features:install ode

When using vanilla ServiceMix, download Apache ODE JBI from here: http://ode.apache.org/download.html and copy it to SM's deploy directory.

Once successfully installed, nmr:list should print you the following three new endpoints:

OdeBpelEngine
{http://www.apache.org/ode/pmapi}ProcessManagementService:ProcessManagementPort
{http://www.apache.org/ode/pmapi}InstanceManagementService:InstanceManagementPort

Exposing Process and Instance Management API Web Services

In my nuntius.eti.pg.gda.pl system I use these Web Services quite heavily, I needed them to be exposed over HTTP.

The solution was quite simple. All I had to do was to write CXF BCs and pass messages to corresponding NMR endpoints.

Using FUSE Maven2 CXF BC OSGi archetype I created project stub. I removed all Java sources and Apache CXF code gen plugin definition from pom.xml file. Also, I removed person.wsdl file from wsdl directory.

First I had to copy Apache ODE Process and Instance Management API WSDLs. I simply copied them from my current Apache ODE war distribution. I copied pmapi.wsdl, pmapi.xsd, and deploy.wsdl (unfortunately the latter is not exposed to NMR - I will write my own implementation for it, expect a post about it soon) to the wsdl directory.

After I had WSDLs and schemas in place. I had to change WSDLs a little bit (unique endpoints names!).

In both cases (Process and Instance ports) I added SOAP word:

<service name="ProcessManagementService">
    <port name="ProcessManagementSOAPPort" binding="tns:ProcessManagementBinding">
        <soap:address location="http://localhost:8080/ode/processes/ProcessManagement"/>
    </port>
</service>
<service name="InstanceManagementService">
    <port name="InstanceManagementSOAPPort" binding="tns:InstanceManagementBinding">
        <soap:address location="http://localhost:8080/ode/processes/InstanceManagement"/>
    </port>
</service>

I opened META-INF/spring/beans.xml file and replaced JAX-WS definitions with the following two CXF BC definitions, plus of course, the Spring OSGi EndpointExporter:

<cxfbc:consumer wsdl="classpath:wsdl/pmapi.wsdl" targetInterface="pmapi:ProcessManagementPortType" targetService="pmapi:ProcessManagementService" 
 useJBIWrapper="false" useSOAPEnvelope="false" />
 
<cxfbc:consumer wsdl="classpath:wsdl/pmapi.wsdl" targetInterface="pmapi:InstanceManagementPortType" targetService="pmapi:InstanceManagementService" 
 useJBIWrapper="false" useSOAPEnvelope="false" />

<bean class="org.apache.servicemix.common.osgi.EndpointExporter"/>

I built it, and deployed to SM. After starting the bundle I saw two new endpoints:

{http://www.apache.org/ode/pmapi}InstanceManagementService:InstanceManagementSOAPPort
{http://www.apache.org/ode/pmapi}ProcessManagementService:ProcessManagementSOAPPort

Building HelloWorld2 example

When you download Apache ODE JBI distribution it comes with examples and Apache Ant build script.

Just go to, for example, examples/HelloWorld2 and execute:

ant

After successful build copy HelloWorld2 SA zip file to SM's deploy directory.

In nmr:list you should see a new endpoint. You can test it by executing the following command:

ant test

Testing Management SOAP ports

OK, so I had one process installed. I ran soapUI and created a new project for http://localhost:8080/ode/processes/ProcessManagement?wsdl WSDL. From ProcessManagementBinding I selected listAllProcesses operation and invoked it. The response was:

<listAllProcessesResponse xmlns:axis2ns1="http://www.apache.org/ode/pmapi" xmlns="http://www.apache.org/ode/pmapi">
   <process-info-list xmlns="">
      <process-info xmlns:ns="http://www.apache.org/ode/pmapi/types/2006/08/02/" xmlns="http://www.apache.org/ode/pmapi/types/2006/08/02/">
         <pid>{urn:/HeaderTest.bpel}HelloWorld2-0</pid>
         <status>ACTIVE</status>
         <version>0</version>
         <definition-info>
            <process-name xmlns:head="urn:/HeaderTest.bpel">head:HelloWorld2</process-name>
         </definition-info>
         <deployment-info>
            <package>HelloWorld2-process</package>
            <document>HelloWorld2.bpel</document>
            <deploy-date>2010-06-16T08:19:10.312+02:00</deploy-date>
            <deployer/>
         </deployment-info>
         <instance-summary>
            <instances count="0" state="ACTIVE"/>
            <instances count="1" state="COMPLETED"/>
            <instances count="0" state="ERROR"/>
            <instances count="0" state="FAILED"/>
            <instances count="0" state="SUSPENDED"/>
            <instances count="0" state="TERMINATED"/>
         </instance-summary>
         <properties/>
         <endpoints/>
         <documents>
            <document>
               <name>HelloWorld2.bpel</name>
               <type>http://schemas.xmlsoap.org/ws/2004/03/business-process/</type>
               <source>file:/C:/Studies/Programs/apache-servicemix-4.2.0-fuse-01-00/data/jbi/HelloWorld2-SA/sus/HelloWorld2-process/HelloWorld2.bpel</source>
            </document>
            <document>
               <name>HelloWorld2.cbp</name>
               <type>http://www.fivesight.com/schemas/2005/12/19/CompiledBPEL</type>
               <source>file:/C:/Studies/Programs/apache-servicemix-4.2.0-fuse-01-00/data/jbi/HelloWorld2-SA/sus/HelloWorld2-process/HelloWorld2.cbp</source>
            </document>
            <document>
               <name>HelloWorld2.wsdl</name>
               <type>http://schemas.xmlsoap.org/wsdl/</type>
               <source>file:/C:/Studies/Programs/apache-servicemix-4.2.0-fuse-01-00/data/jbi/HelloWorld2-SA/sus/HelloWorld2-process/HelloWorld2.wsdl</source>
            </document>
         </documents>
      </process-info>
   </process-info-list>
</listAllProcessesResponse>

The BC worked as expected.

Summary

What next? Maybe enterprise grade JMS and Apache Camel? We'll see.

Stay tuned,
Łukasz

2 comments:

Marco Ingrosso said...

Hi, I tried to follow the steps you described, but no success.
A zip file with the project could be a valid help.
Something's missing, i.e:
1) I had to add the following definition in beans.xml: xmlns:cxfbc="http://servicemix.apache.org/cxfbc/1.0"
2) I had to add the following package in Import-package node in pom.xml: org.apache.servicemix.common.osgi

Everything seems to be successfully deployed, but the Url "http://localhost:8080/ode/processes/ProcessManagement?wsdl" gives a 404 Error.

Have a nice day, Marco.

Marco Ingrosso said...

I solved adding another missing definition in "beans.xml" i.e. xmlns:pmapi="http://www.apache.org/ode/pmapi".
Have a nice day,

Marco