Developing BPEL processes in Eclipse BPEL Designer and WSO2 Business Process Server
- By Keheliya Gallaba
- 31 Aug, 2010
BPEL (Business Process Execution Language) is an OASIS standard executable language for specifying various interactions with Web Services enabling composition, orchestration, and coordination between them. The WSO2 BPS is an open source business process server, developed on top of Apache ODE and executes business processes written using the WS-BPEL standard. For a basic introduction on business processes orchestration, BPEL and BPS refer to the guide on ‘Writing a simple WS-BPEL process for WSO2 BPS and Apache ODE’ here.
Purpose of this article is to give a basic introduction of creation and deployment of BPEL processes in WSO2 BPS using Eclipse BPEL Designer and WSO2 BPS BPEL Exporter Eclipse Plugin.
- Tutorial Scenario
- Getting Started
- Developing a BPEL Process using Eclipse BPEL Designer
- Create a new BPEL project
- Create a new BPEL process file in the project
- Create the BPEL Process Diagram
- Modify the service description file
- Set the partner links for the BPEL process
- Set the properties of assign activities
- Define the Service binding type and port type address
- Write the deployment descriptor
- Deploying in WSO2 BPS Using WSO2 BPS Exporter Plug-in
- Create the archive for deployment
- Deploying the archive in WSO2 BPS
This tutorial shows how to describe a business process in BPEL by using Eclipse BPEL designer plug-in and deploy it in WSO2 BPS using BPEL exporter plug-in. The scenario that we present here calculates the area limited by a rectangle and an ellipse inscribed in that rectangle by executing a business process which invokes three other external Web services.
We are going to calculate the area marked in red using the business process.
Rectangle Computation Service calculates the area of a rectangle when the length and height parameters are given. You can find the service description of that service here
Ellipse Computation Service calculates the area of a rectangle when the following dimensions are provided. Service Description available here
Simple Computation Service available with Service Description available here provides all the basic mathematical operations. The process for calculating the area can be described by a diagram like this. A client can invoke the Area service and include height and length as input parameters.
For developing and deploying the BPEL process explained in this tutorial, it is required to have the following applications installed in your machine.
- Java Runtime Environment 1.5 or above
- Eclipse SDK 3.5 (Eclipse Galileo)
- Apache ODE
- WSO2 BPS
- BPEL Designer - Eclipse Plugin
- WSO2 BPS BPEL Exporter - Eclipse Plugin
Step 1: Create a new BPEL project
Open Eclipse IDE. Go to File → New → Project → BPEL 2.0 → BPEL Project
Click Next. Give the name of the project as WS_Area. Select Target Runtime as Apache ODE 1.x Runtime. Under Configuration section, click Modify
In the Project Facets Dialog, select BPEL 2.0 Facet and click OK.
Click Finish to create the new BPEL project in the workspace
Step 2: Create a new BPEL process file in the project
Right click the project WS_Area in the project explorer and select New → Other → BPEL 2.0 → New BPEL Process File
Click Next. Type AreaService as the BPEL Process Name and https://areasearvice.bpel.bps as the Namespace. Select Synchronous BPEL Process for theTemplate and click Finish.
Step 3: Create the BPEL process diagram
Now we need to create a BPEL Process similar to the following. Scroll below to find the exact steps for doing that
3.1 Add an assign activity between receiveInput and replyOutput activities by dragging from Actions sections of the palette
3.2 Similarly, add a flow to the diagram by dragging from Control2 section of the palette.
3.3 Add a sequence inside that flow
3.4 Add an invoke activity inside that flow and rename it into InvokeRectangleAreaService.
3.5 Add another sequence inside the flow.
3.6 Similarly you can complete the diagram as Figure 3 and make sure all the diagram components have the similar names as of those in Figure 3.
Step 4: Modify the service description file AreaServiceArtifacts.wsdl
Open AreaServiceArtifacts.wsdl and click the arrow next to AreaServiceRequest.
In the Outline view, go to Elements→AreaServiceRequest→LocalType→Sequence and rename the variable input to a and set its type to int
Right click sequence and add a new element. Change its name to b and set its type to int. In the Outline view, go to Elements→AreaServiceRequest→LocalType→Sequence→result and set its type to double and Save the file.
Step 5: Set the partner links for the BPEL process
Download the service description files of Simple Calculator Service, Rectangle Area Service, and Ellipse Area Service from following links and copy them to the project.
5.1 Set the properties for InvokeRectangleAreaService activity
In the BPEL diagram, click the InvokeRectangleAreaService activity and go to the Properties view. In details tab of the Properties view, select Partner Link → Create Global Partner Link and name it as RectangleAreaPL. Click OK.
In the Choose Partner Link Type dialog select From Project option and make sure the Show Port Types Filter is selected. Then select theRectangleCalculator interface and RectangleCalculator as the partner link type structure. Click OK.
In the next dialog, enter the partner link type name as RectangleAreaPLT and click Next. Give the role name as RectangleAreaPLRole and selectRectangleCalculator as the port type.Click Next and ignore the second role of the partner link and click Finish.
Select the operation area from Quick Pick: This will automatically generate Input Variable, RectangleAreaPLRequest and Output Variable,RectangleAreaPLResponse. Then save the file.
5.2 Set the properties for InvokeDivideHeightService activity
In the BPEL diagram, click the InvokeDivideHeightService activity and repeat the steps in 5.2 giving following values to the parameters mentioned in the parantheses.
- SimpleCompoutationPL (partner link name)
- SimpleComputation (matches)
- SimpleComputation (partner link type structure)
- SimpleCompoutationPLT (partner link type name)
- SimpleCompoutationRole (Role Name). Here, select SimpleComputation as the port type and finally, skip the second role of the partner link.
Select divideOfTwoDouble operation from drop down list of the Operation field.
Create two new variables for Input Variable and Output Variable fields. To do that, select create Global Input Variable from the drop down list of Input Variable and name it as DividePLRequest1. Similarly, create a new Output Variable and name it as DividePLResponse1.
Now we need to set the correct types for these two variables.
Select the DividePLRequest1 variable either from the Palette or the Outline view. Go to the Details tab of the properties view.
Click Browse to select a message type.
In the Choose type of variable dialog, select From workspace option and keep only the Messages filter selected. From the Matches and Type Structure lists, select divideOfTwoDoubleRequest and click OK.
Likewise set the Message Type of DividePLResponse1 to divideOfTwoDoubleResponse
Similarly, for InvokeDivideLengthService activity, set the partner link to SimpleComputationPL and Operation to divideOfTwoDouble.
Create two input and output variables named DividePLRequest2 and DividePLResponse2 respectively and set their types correctly todivideOfTwoDoubleRequest and divideOfTwoDoubleResponse respectively.
5.3 Set the properties of InvokeEllipseAreaService activity
Click InvokeEllipseAreaService activity. In the Details tab of the properties view, create a new global partner link as EllipseAreaPL. SelectEllipseCalculator in Matches and Partner link Type Structure lists.Click OK.
Name the partner link type as EllipseAreaPLT and click Next. Give the role name as EllipseAreaPLRole. Select EllipseCalculator as the port type. Skip the next role name and click Finish.
Select area operation from EllipseAreaPL → EllipseCalculator under Quick Pick. The input variable EllipseAreaPLRequest and the output variableEllipseAreaPLResponse will be generated by that step. Save the file. Make sure that the message types of these variables are set to AreaRequest andAreaResponse respectively. (You can view message types for variables in Details tab of properties view of each variable.)
5.4 Set properties for InvokeSubtractionService activity.
In the Details tab, set the partner link as SimpleComputationPL. Select the operation subtractionOfTwoDoubles from QuickPick and the input and output variables SimpleComputationPLRequest and SimpleComputationPLResponse will be created. Make sure those variables are of message typesubtractionOfTwoDoubleRequest and subtractionOfTwoDoubleResponse. (You can view message types for variables in Details tab of properties view of each variable.)
Step 6: Set the properties of assign activities
6.1 Set the Assign activity
Click the Assign activity. In its properties view, select Details → New to create a new assignment and assign the variable input→payload→a to the variableRectangleAreaPLRequest→parameters→h. Make sure that you select Yes for the variable initialization message box. Similarly, assign input→payload→bto the variable RectangleAreaPLRequest→parameters→b. Save the file.
Click New, In the same manner, assign the variable input→payload→a to the variable DividePLRequest1→parameters→dividor.
Make sure that you select Yes for the variable initialization message box. Save the file.
Click New and select Fixed value to the From: field to assign the fixed value of 2 to the variable DividePLRequest1→parameters→dividend.
In the same manner, create a new assignment by clicking New and assign the variable input→payload→b to the variable DividePLRequest2→parameters→dividor. Make sure that you select Yes for the variable initialization message box.
Create a new assignment to assign the fixed value of 2 to the variable DividePLRequest2→parameters→dividend and save the file.
6.2 Set the Assign1 activity
Create a new assignment and assign the variable DividePLResponse1→parameters→divideOfTwoDoubleReturn to the variable EllipseAreaPLRequest→parameters→a. Select Yes for the variable initiation message box. Similarly, in a new assignment, assign the variable DividePLResponse2→parameters→divideOfTwoDoubleReturn to the variable EllipseAreaPLRequest→parameters→b and save the file.
6.3 Set the Assign2 activity
Assign the variable RectangleAreaPLResponse→parameters→areaReturn to SimpleComputationPLRequest→parameters→x by creating a new assignment. Select Yes for the variable initiation message box. In a new assignment, assign the variable EllipseAreaPLResponse→parameters→areaReturnto SimpleComputationPLRequest→parameters→y and save the file.
6.4 Set the Assign3 activity
In a new assignment, assign the variable SimpleComputationPLResponse→parameters→subtractionOfTwoDoubleReturn to output→payload→result. Select Yes for the variable initiation message box and save the file.
Step 7: Define the Service binding type and port type address
Right click the AreaSearviceArtifacts.wsdl and select Open with → WSDL Editor. Right click the empty space of the WSDL Editor and select Add Binding. In the Properties view, set the name of the new binding as AreaBinding and select PortType as AreaService.
Click on Generate Binding Content button. Select the protocol as SOAP and SOAP Binding Options as the document literal in the Binding wizard. Click Finish.
Right click the empty space of the WSDL Editor again, select Add Service. Rename the service as AreaService.
Click the NewPort part below the service's name. Then, in the Properties view, change the port's name to AreaPort. Select the Binding as AreaBinding. Set the address to the AreaService process's location on the local server, which is https://localhost:8080/ode/processes/AreaService and the Protocol is SOAP.
After completing the above steps your AreaSearviceArtifacts.wsdl file should look like this
Step 8: Write the deployment descriptor
Right click on the WS_Area project, select New→Others→BPEL 2.0→Apache ODE Deployment Descriptor. Click Next.
Verify that the BPEL Project name is set to /WS_Area. Click Finish.
Right click the deployment descriptor file(deploy.xml). Select Open With→ODE Deployment Descriptor Editor. At the Inbound Interfaces (Services), setPartner Link to client. Select the Associated Port as AreaPort and click on any other field. Eclipse will automatically fill in other fields. At the Outbound Interfaces (Invokes), select following associated ports for the respective partner links.
Step 9: Create the archive for deployment
Right click the WS_Area project, select Export→WSO2 Exporter →WSO2 BPS BPEL artifact. Click Next.
Make sure that the project WS_Area is selected, and browse to the location, for zip archive to be created. Click Finish.
If the export was successful, the newly created archive should contain the following files.
The process file
Service Description files
Deployment Descriptor File
Step 10: Deploying the archive in WSO2 BPS
When you successfully start the server and login, you will be greeted by a welcome screen like this
Click Add BPEL in the Business processes tab
Upload the BPEL package by selecting the path where you created the zip archive
If the BPEL had compiled correctly it will be deployed successfully and greet you with a success message
Click Processes in the Business processes tab
You can see the newly deployed process in the table.
Try out the newly deployed process by clicking Try AreaService
- Invoke a Web service with Eclipse BPEL designer and Apache ODE by Nguyen Ngoc Chan - https://www-inf.it-sudparis.eu/~nguyen_n/teaching_assistant/bpel/invoke_a_web_service_with_eclipse_bpel_designer_and_apache_ode
- Writing a simple WS-BPEL process for WSO2 BPS and Apache ODE by Denis Weerasiri - https://wso2.org/library/articles/writing-simple-ws-bpel-process-wso2-bps-apache-ode
- Developing a simple Bpel project with Eclipse Bpel Designer Plugin and WSO2 BPS Bpel Exporter Plugin by Chathuri Wimalasena - https://wso2.org/library/tutorials/developing-simple-bpel-project-eclipse-bpel-designer-plugin-wso2-bps-bpel-exporter-plugin
- OASIS (Organization for the Advancement of Structured Information Standards) - https://www.oasis-open.org
- Web Services Business Process Execution Language Version 2.0 - https://docs.oasis-open.org/wsbpel/2.0/OS/wsbpel-v2.0-OS.html
- WSO2 BPS - https://wso2.org/projects/bps
- Apache ODE - https://ode.apache.org/
Keheliya Gallaba, Intern, WSO2.