This tutorial demonstrate how to develop a BPEL process using WSO2 Developer studio 2.0 for Apche ODE and WSO2 Business Process Server. WS-BPEL (Business process execution language for Web services) is a language used for composition, orchestration, and coordination of web services. It is a rich language to express the behaviour of business processes. Apache ODE (Apache Orchestration Director Engine) is a system for executing long running processes described using the WS-BPEL standards. WSO2 Developer Studio is a complete tooling platform where you can develop, deploy, test and debug your SOA applications in a very user-friendly manner.
We have web service to expose simple day to day banking operations. Those are
For deploying the WS-BPEL process explained in this tutorial, it is required to have the following applications installed in your machine.
As we discussed earlier now we are going to deploy our back-end axis2 services. To maintain the simplicity of the tutorial and for ease of use, we use the sample axis2 service shipped with WSO2 developer studio. To import sample in to your workspace
1.1 Go to Developer Studio -> Samples and click on the sub menu item labeled with Axis2 Account Service as shown in the figure below.
Note :-To use this sample you have to build it by maven because it needs some dependencies to be fulfilled. And also make sure to refresh the project in the workspace and build it (using eclipse) before trying to deploy.
Download the Apache Axis2 Server from here extract the zip file and start the axis2 server (for this tutorial we assume axis2 server up and running on localhost port 8080)
1.2 Right click on the imported project, select the menu item, Export Project as Deployable Archive as shown in the below image.
1.3 Use the Browse button on the pop up wizard to point the location of the file system to save the .aar file.
If the .aar file correctly deployed on the axis2 console INFO smiler to below will be printed.
Now we have successfully completed the first step of our tutorial.
Note :- You can use the axis2 client that shipped with the Account Service Sample to test the sample. Traverse down the class call AccountServiceClient in the client package and just run it self explaining console output will print.
1.4 Generate the WSDL of AccountServiceSample.
As you can see the above image of right click menu of the AccountServiceSample project selecting the Generate WSDL option you can generate WSDL and point it to any system location you want.
2.1 Creating BPEL Project.
Click on Open Dashboard option on Developer studio menu we have seen earlier. It will open the WSO2 Developer studio dashboard shown as below.
Click on the BPEL Workflow link button under the Business Process Server category.
2.1.1 It will trigger the Create New BPEL Project wizard as below.
Select the Create New BPEL Workflow option and press Next button and give a name for the BPEL process. Select the Template as "Synchronous BPEL process" as shown in Figure 2.3
we can change the maven information here if we need. WSO2 Developer Studio has the full maven integration support for all the project types created using it.
The project structure created by the wizard will be same as below.
2.2 Developing BPEL process.
Note : - Change the perspective to BPEL by Window - > Open Perspective -> Other -> BPEL Perspective.
Now we need the WSDL of the AccountServiceSample service. For that just right click the AccountServiceSample project and select the menu option Generate WSDL. Point the generated WSDL in to AccountDemoProcess project.
Open the BPEL on BPEL editor and Remove the dummy component from the created BPEL. Go to Control2 category in BPEL editor and select Sequence element from there and drag & drop it to just after the receiveInput element.
Now we need to add invoke element to call the create account operation. For that go to Actions category, select Invoke, drag & drop in to the AccDemoSeq.
Click on the CretaeAccountOperationInvoke element and go to the Details tab in properties view, select the combo box infront of the Partner Link filed. Select the Create Globle partner Link option.
Click on the Add WSDL button, point the AccountService.wsdl that we added earlier to the AccountServiceDemoProcess. Click the OK button. It will pop up the Create New Partner Link Type dialog, give the name of Partner Link Type as
In the next pop up dialog give a name for the partner link AccountServicePLT
On the next dialog window it will ask for the role for this partner link type. Give the role name as AccountServiceRole and select the port type as AccountServicePortType as shown below.
Click on the finish button. Now we have to select the operation for this invocation. Back again to the properties view and select the createAccount operation from the combo box as below.
Note : - make sure to select the operation and double click the same operation on quick pick view on the right side. It will generate the request response configurations for us. Otherwise when we are in the variable assignment level we will have unwanted problems.
Before we go further we should rename the variables for the sake of convenience. We can select the variable from the Variables section as shown below and using properties view we can change the names.
As per the WSDL cretaeAccount operation take string argument (dummy) and return newly created account number as an integer value. So we have to give the dummy assignment to that operation. For that, add assign element from the palette. To configure the assignment click on the assign element, go to properties view, select details tab, click on new button.
The next step we want to add some credits to the newly created account. For that we have to invoke the creditAccount Operation. But the creditAccount operation takes the account number and the amount as arguments. Same as above we can add the creditAccount operation as an invoke element.
To take the account number and submit it to crditAccount Operation we have to add assign element from the palette after the createAccount operation as below. Give the name of the assignment as AssignAccNumTocreditAccOp.
As we discussed earlier now we need to creditAccountOperation = output of the creteAccountOperation. Now it is very easy to do the assignment.
Editor will ask to initialize the variables - if you don't allow it, we have to take care of the initialization. For ease we are hard coding the credit amount. To do that click New button and again and change the From : combobox to Expression and put ‘12000’ to the editable text box. On the To : section traverse to creaateAccountRequest -> parameters -> amount select it. Then the credit amount will set to 12000 when the operation is invoked.
now we need to check the state of credit account operation. For that we are using if element. Drag and drop the If element from the palate as shown below. Name it as CheckCreditState. We need to set the condition. Go to the properties view and details tab, click on Create New Condition button. Copy and paste below expression in the editable area.
$creditAccountResponse.parameters/ns:return = true
Now it's time to invoke check balance service depending on the condition that we have set. Drag and drop invoke element to the if block as shown in the below image and configure it to invoke the check balance service, as described above.
And also we need to submit the account number to this operation. We achieve that by using the assign element described above.
Now we need to copy the checkbalance operation out put to reply out put element. For that we can add assign element same as before.
so what about when the if condition fails? We need to add else element by right click on the if block and selection Add Else option. Drag and drop an assign element on to it and configure it to assign false to reply on element. The Final BPEL process will be like below.
And also make sure the deploy.xml configurations are set as below.
3.1 Deploy in Apache ODE.
Right click on your AccountServiceDemoProcess project and select the Export project As a Deployable Archive. Locate the file system location that you want to save the artifact.
It will create AccountServiceDemoProcess_1.0.0.zip file. Go to Apache ODE management console, select deployment tab, give the process name as AccountServiceDemoProcess and locate the artifact file that we have created from the system and click on ok. Or put the extracted zip content in to directory call AccountServiceDemoProcess in ODE installation directory/WEB_INF/processes. Now you can try the process using Apache ODE.
3.2 Deploy in WSO2 BPS (WSO2 Business Process Server)
You can download the WSO2 BPS from here and go to installation directory, then go to the bin directory. If you are using Linux, run the shell script call wso2server.sh or in Windows run the wso2server.bat file to start the server. You can create the deployable archive via above option and go to the management console of WSO2 BPS by https://localhost:9443/carbon/ and login to the management console using admin and user name and password. The management console will be shown as below.
Click on the button labeled with Add BPEL on the left panel It will lead you to the below page, from there you can upload the .zip file you have created using WSO2 Developer Studio.
You can try out the process using try it tool on WSO2 BPS. Figure 3.4 shows the output.
Source Code and the axis2 archive can be downloaded from attachment section below.
In this articale we demonstrate how we use WSO2 Developer Studio to develop, test and deploy business processes for Apache ODE and WSO2 Business Process Server. All the important points were discussed where you can try out the above scenario using given source resources.
Kalpa Senanayake, Software Engineer , WSO2 Inc