A BPEL process without using vendor specific extensions should run everywhere without much hassle. But unfortunately it doesn’t. In this article I will show you how to create a BPEL process with Netbeans and what changes you have to make to make it run on Apache ODE.
A while ago I wrote an article about testing BPEL-processes on ODE with SoapUI. When I started that article the idea was to create my own process with the Eclipse BPEL-editor. At that moment it took me enough time to deploy an example process on ODE, so I decided to skip that part.
Recently I found out Netbeans also has a BPEL-editor. I tried to deploy a process on Glassfish and again that didn’t work as easy as it should.
The only solution to these kind of problems is dissecting example files and reading tutorials. Reading tutorials is of course the first step. Unfortunately there isn’t much to read for beginners. A blog by a guy named Julien got me started, but it after a while I gave up and looked for the example files.
Dissecting the HelloWorld2 example
I used the HelloWorld2 example from my previous blog about BPEL and decided to print out the deploy.xml, HelloWorld2.bpel and HelloWorld2.wsdl files and compare them with the files Netbeans creates.
I won’t bother you with the comparisons, I’ll just show you what you have to add to make the files ODE-compliant.
Creating a BPEL process in Netbeans
For this article I used Netbeans 6.1 (make sure you download the largest version, this one includes the SOA plugins)
Create a new BPEL module by creating a new project (in the SOA folder). Call this process the LsoModule. Now we have to create a WSDL to define the input and output parameters. Right click the LsoModule, New, WSDL Document
Call the file lsoWsdl and change the target namespace:
click next and change the input and output parameter names:
Click finish and your WSDL is created
The file lsoWSDL.wsdl is opened. The next step is creating a service. We need a service to group portTypes and assign a url for ODE. This can be done by right clicking the services folder. Also add a port and a soap address. Change the names of the object so it matches this screenshot:
The address must match the address of your ODE deployment suffixed with /processes/procesName
The service must be bound to the process with a binding. A binding defines the interface and protocol details for the outside world. Right click bindings and add a binding and click ok. Right click the LsoPort and set the binding to the binding you just created.
Now we can create the BPEL process. Right click the LsoModule, New, BPEL Process
Name the process lsoProcess with namespace http://www.amis.nl/bpel/LsoModule/lsoProcess
The BPEL-file opens and is of course empty.
To give the process an interface (the WSDL we created a minute ago) drag the .wsdl to the center of a swimlane (the grey things at the right and left of the process). An orange dot will appear, meaning you can release your mouse button
When your mouse button is released a PartnerLink will appear. Double click this partner link to change its name to LsoPartnerLink.
The process now needs to be connected to the partner link. Drag a Receive from the web palette to the center of the process. An icon with an envelope will appear. Drag this envelope to the envelope of the LsoPartnerLink. A green arrow will point from the LsoPartnerLink to the Receive.
You’ll probably also noticed the red circle with a white x in it. These errors should never be ignored, your process won’t work properly when there are errors.
When you click the error you will be informed a reply is missing and there is no input variable.
To add a variable click the envelope, a small edit icon will appear above the Receive.
Click the create button to create a new variable. For now it’s okay to use the name LsoWSDLOperationIn so it’s clear where this variable is coming from.
Drag a reply from the palette just under the Receive (an orange dot indicates the release point). Connect to the LsoPartnerLink by dragging from the center of the Reply to the LsoPartnerLink.
Create an output variable the same way as you created the input variable (call it LsoWSDLOperationOut)
Now our process takes input and gives output. Normally your process would do something with this input and output, this process doesn’t. It just returns the input,
To do this you’ll need an Assign operation. Drag an Assign between the Receive and Reply. Now connect the input to the output:
Our process is now finished. Now the deploy.xml for ODE needs to be created.
Creating the deploy.xml
It’s a lot of manual work to create the deploy.xml and you have to be very precise. I took the deploy.xml from the HelloWorld2 example from ODE and changed it.
The first change is the pns (probably stands for process name space). This is the namespace you use in the .bpel file (the targetNamespace in the root element).
The following change is the wns (WSDL name space). This is the targetNamespace from the .wsdl file.
Next we have the process name. This is pns followed by a colon and the process name from the .bpel file.
The fourth change is the partner link. The link name can be found in the .bpel file.
The final changes are in the service tag. The values can be found in the .wsdl file
After all the changes are applied you will have this xml file:
<p><?xml version="1.0" encoding="utf-8" ?><br /><br /><deploy xmlns="http://www.apache.org/ode/schemas/dd/2007/03"<br /><br /> xmlns:pns="http://www.amis.nl/bpel/LsoModule/lsoProcess"<br /><br /> xmlns:wns="http://www.amis.nl/wsdl/lsoWSDL"><br /><br /> <process name="pns:lsoProcess"><br /><br /> <active>true</active><br /><br /> <provide partnerLink="LsoPartnerLink"><br /><br /> <service name="wns:LsoService" port="LsoPort"/><br /><br /> </provide><br /><br /> </process><br /><br /></deploy> <br /></p>
Deploying the files
To deploy the process create a directory named LsoService under <tomcat-dir>/webapps/ode/WEB-INF/processes (assuming you already have ODE running). Copy the three files (deploy.xml, lsoProcess.bpel and lsoWSDL.wsdl) to this directory.
When your deployment was successful you’ll see the lsoService at http://localhost:8080/ode/services/listServices. The link to the lsoService can be used with SoapUI to test this service:
When you update the files in the directory the changes are not detected. To redeploy the process you have to remove LsoService.deployed in the processes directory (it immediately will re-appear because the process is deployed again).