The Quick Start guide explains how to set up and start the WSO2 BPS, model a BPEL process, deploy and test it using the WSO2 BPS management console. The guide has the following sections:
How do I...?
Set up BPS
WSO2 BPS setup is very simple. While more details of the installation can be found in the Getting Started section, this guide provides a basic summary to get you started fast.
- Ensure that the following are installed in your environment.
- JDK 1.6.* or higher.
- JAVA_HOME environment variable is set to
<JDK_HOME>
. For example,JAVA_HOME=c:\Program Files\java\jdk1.6.0_27
.
- Download the BPS binary distribution from http://wso2.com/products/business-process-server/.
- Extract the zip file to a folder which will be referred to as
<PRODUCT_HOME>
throughout the rest of this guide. - Open a command prompt (or a shell in Linux) and go to the
<PRODUCT_HOME>\bin
directory. - Start the BPS server by executing wso2server.sh (or wso2server.bat in Windows).
- The operation log keeps running until the server starts, which usually takes several seconds. Wait until the server fully boots up and displays a message similar to "WSO2 Carbon started in n seconds."
Model a BPEL process
- Download and setup WSO2 Developer Studio. (http://wso2.com/products/developer-studio)
- Open the Developer Studio and select File > New > Other.
- From the window that appears, select Carbon Application Project and click Next.
- Provide a suitable name to the Carbon application project. For the purposes of this example, name it as "WS_NumberAdderCarbon". Click Finish once done.
The Carbon application project is created and you can see it on Project Explore pane on the left of your Developer Studio screen. - Create a new BPEL project. To do this, right-click on the project which is on the Project Explore pane and choose New > BPEL WorkFlow.
- On the “Create New BPEL Project” wizard, select Create New BPEL workflow and click Next to continue.
- Provide suitable names, a namespace and select the matching template for your BPEL process and project.
- In this example, we use "BPELNumberAdder" as the project name. Also provide a valid namespace as the process namespace. Since we are creating the synchronous business process, select the template “Synchronous BPEL Process”.
- Process Name : AdderProcess
- Namespace : http://NumberAdder.com
- Template : Synchronous BPEL Process
- Click Finish to close the wizard.
- Expand the "WS_NumberAdderCarbon" project folder in the "Project Explore" pane to view another folder named "BPELNumberAdder". The "BPELNumberAdder" project is used here for BPEL process development. The “Project Explorer” window and the AdderProcess.bpel file will look like the following.
This point onwards you have to design your BPEL process by adding business logic to the BPEL process. In this guide we will be designing a simple process to add two integers. - Open “AdderProcessArtifacts.wsdl” file in BPELNumberAdder Project in order to set input parameters. Click on the arrow next to "Adder Process Request".
It will open another tab called “Inline Schema of Add”. By default it will have a single variable named “input” with type string. Rename it as x and set the type to int. - You need to add another element. To add another element right-click on "AdderProcessRequestType" and “add an element” after it. Name it "y" and set the "type" as "int". Now it should look like the follwing image.
Now lets design the simple business logic. Open the AdderProcess.bpel file. You need to add business logic in the place of where “FIX_ME-Add_Business_Logic_Here” activity resides. Delete the “FIX_ME-Add_Business_Logic_Here” element. You will have the following process.
To delete, right-click on the element and choose delete.
Now you need to add an Assign activity in between “receiveInput” and “callbackClient” activities. To add Assign activity drag it from the Action section of the Action Palette.
Another way to add activity element to the editor is right-click on element and use add-before option.
- Now you need to configure Assign activity. Click on “Assign” element which is on BPEL process and then click on “Details” tab in ”property window”.
- Click on “New” which will lead you to the following view in “property window”
- We will use an Xpath expression to compute the addition of two variables and assign the result to the output variable. To do that choose “Expression” from “From” drop down list and choose “Variable” from “To” drop down list.
- Choose “Xpath 1.0 in BPEL 2.0 ” as Expression Language.
- The Expression which we need to evaluate is “ $input.payload/tns:x + $input.payload/tns:y ”. Include this in the box below “Expression Language”.
- Select “result:string” under “To” as the assigned variable.
- While you configure the variables, The editor will send you a message asking you to initialize the variables. Click Yes. It will automatically generate an XML string for variable initialization. The property window of Assign activity should look like the following once you have completed the steps.
- Now you need to define inbound and out bound interfaces. Open the deploy.xml file which is in the BPEL project. Choose
AdderProcessPort
as the inbound address port from the given list. The rest of the parameters will be automatically filled once you select it. There will not be any ports for outbound interfaces as we do not have external invocations in this business process. - Include the BPEL process as a dependency of the Carbon Application (WS_NumberAdderCarbon). To include it, open “pom.xml” of Carbon application project and select BPELNumberAdder as a dependency.
Deploy and test the BPEL process
After modelling the BPEL process, it can be deployed in the WSO2 BPS.
- In Developer Studio, right-click on the "Servers" window and select New -> Server. If it is not visible, select Window -> Show View -> Servers.
- The New Server window appears. From the List, expand the WSO2 folder and select WSO2 Carbon 4.0 based server as shown below. Carbon 4.0 based server is selected here since BPS 3.0.0 is based on Carbon 4.0.2. If needed, specify the Server name here. In this example, we specify it as WSO2 BPS. Click Next.
- Set the
CARBON_HOME
by clicking the Browse button and selecting WSO2 Business Process Server home folder. Click Finish once done or Next if more settings of the server need to be configured such as the 'service port', 'web console port' etc. - Once done, WSO2 BPS is added to Servers List as shown below.
- The next step is to deploy the carbon application in WSO2 BPS. Simply click on "WS_NumberAdderCarbon" project in "Project Explore" window and drag and drop it on Server. The server will be automatically started.
- If the server does not get started automatically, run the server by right-clicking on it and selecting "Start". In Console window, note the server process's log.
- WSO2 BPS login page will be opened automatically in the default web browser. Login using admin as username and admin as password.
Select "processes →list" menu from the "Main" menu. The "Deployed Processes" window opens with the "AdderProcess" deployed.
The "Process ID" is generated in the format
{"Process NameSpace"} ProcessName-VersionNo
. Click the Process ID.- The "Process Information" window appears with the details of the process. Click on the "Try It" link.
- A browser window opens to enter the required input parameters. Enter the values and click "Send" for the answer.
Alternatively, you can use the SOAP UI tool to test a business process. The SOAP UI application shows the request/response soap messages and is particularly helpful in error handling.
Model a BPMN process
Download and setup Eclipse (Recommended Packs - 3.7 - 4.2.1 (Indigo - Juno) or 4.3 (Kepler)).
Note: The instructions in this section are verified on Eclipse Kepler and Indigo. Note that Eclipse Helios is NOT supported.
- Under the Help menu, click Install New Software. In the resulting panel, click the Add button to add a repository and fill in the following fields:
Fill in the following repository details for BPMN.- Name: Activiti BPMN 2.0 designer
- Location: http://activiti.org/designer/update/
- Click OK to add the plugin. Once this is done, click Finish and restart Eclipse.
- Once Eclipse restarts, navigate to File > New > Other. From the window that appears select Activiti > Activiti Project and click Next.
Provide a suitable Project Name and click Finish.
Right click on your project and navigate to New > Other.
From the window that appears, select Activiti > Activiti Diagram.
Select the project in the viewer and enter a File name.
Tip: The following example expands on creating a business process scenario, The manager invokes an order approval process where it is possible to set the product ID. Additionally, an employee from a good division can set the quantity and the unit price of the product. The quantity and the unit price are used to calculate the total cost. If the total cost is above 100,000, the order will have to be approved by an employee from the the orderApproval Group before the order mail is dispatched. Alternatively, if the cost is below 100,000, the order mail is dispatched without approval. In this example, the process is named “OrderApproval”.
- Click Finish. You are presented with a canvas as shown below to model your BPMN package.
The palette is positioned on the right side of the screen. You can drag and drop models from the palette onto the canvas and do your modelling. - To implement the OrderApproval, drag and drop a Start Event element, two User Task elements, a Mail Task element and a Terminate Event element on the canvas.
Link up the flow according to the business logic.
Tip: According to the business logic in this example, the Start Event should trigger the Fill Order Form User Task. So connect the Start Event to the Fill Order Form User Task.
In the Connection tab, select Sequence Flow. Connect the Start Event to the Fill Order Form User Task.
Tip: It is useful to understand the condition logic for this sequence. Here, if the total cost calculated from the quantity and unit price is above 100,000 a user task has to be executed or the mail task comes into play. In order to add this condition statement, click on the Fill Order Form User Task and you will be able to see few tooltips hovering around the Fill Order Form User Task on the canvas. The diamond shape with a cross in the middle implies an Exclusive Gateway.
- Select the Fill Order Form User Task by clicking on it and click on the Exclusive Gateway tooltip on the right of the tool.
- Once you click the Exclusive Gateway, a bigger diamond with a cross in the middle should appear on the canvas next to the Fill Order Form User Task. The Fill Order Form User Task will point to it.
- The rest of the flow is fairly straightforward. Use the Sequence Flow to connect the tools and the final diagram will be similar to what is shown below.
After the diagram has been constructed, you must configure the properties of each element to fulfil the business logic. Click on the Start Event element and set the following properties in the general tab.
Id: fillOrderDetails
Name: Enter Order Details
- To get the order details, you must create a form to get the product ID from the manager who invokes the process. Click on the Form tab in the properties of the Start Event.
- Click on the New button and use the new window as shown below to create a productID field.
Ensure that you enter the following details.Id: productID
Name: Product Id
Type: string
Variable: productID
- Click OK. Once you have filled the form, the table in the form tab should look similar to the following.
Now that the configurations for the start event have been set, you can configure the Fill Order Form User Task, which is a claimable task by the goods division, where an employee of the goods division will be able to claim and complete the form. - Click on the Fill Order Form User Task. In the Properties tab, assign an Id and Name, similarly to how you assigned a Id and Name to the start event. You can use the following values.
Id: fillOrderForm
Name: Fill Order Form
- Click on the Main Config tab in the Properties pane. Since there is no specific user who the task is to be assigned and anyone from the goods division can claim the task and execute it, set the Candidate Group to goodsDivision. This is will allow any employee under the goods division to claim and complete the task.
Create the form that the employee needs to fill. To do this, click on the Form tab in the Properties pane. Add the following fields in a similar manner to how you added form attributes for the start event.
productID quantity unitPrice Id productID quantity unitPrice Name Product ID Quantity Unit Price Type string int double Variable productID quantity unitPrice Once the above fields are added to the form, the table in your Form tab should look similar to the following.
Now that you have configured your Fill Order Form User Task, you can identify the two flows. There can be a default flow and a conditional flow.
- To assign the default flow, set an appropriate ID for the flow, which is the Sequence Flow element from the exclusive gateway to mail task. Click on this flow.
- Set the Id value as shown below.
- To assign the default flow, set an appropriate ID for the flow, which is the Sequence Flow element from the exclusive gateway to mail task. Click on this flow.
- Similarly, assign an ID to the Sequence Flow from the exclusive gateway to the Approve Order User Task.
- Id: approveOrder
- To set orderProduct as the default flow, do the following.
- Click on the exclusive gateway.
- Click the General tab in the Properties pane and select orderProduct in the dropdown to assign it.
- To assign the Conditional flow, click on the approveOrder Sequence Flow element, navigate to the Main Config tab. In the condition field, define the condition as ${(quantity*unitPrice) < 100000}. This is for calculating the total cost and checking if it exceeds 100,000. If it does, it will take the conditional flow.
You have now configured the conditional flow. If the total cost exceeds 100,000, the flow is directed to the Approve Order User Task. To configure the Approve Order User Task, do the following.
Click on the Approve Order User Task.
In the General tab, assign an appropriate ID and Name.
In the Main Config tab, you must set the Candidate Group as the “orderApproval” group, as according to the scenario, anyone from the order approval group can claim the task and complete the task.
To allow the approver to view the order details, you must create a form to display the Product ID, Quantity and Unit Price. To do this, navigate to the Form tab in the Properties pane and create the fields as show in the diagram below.
Note: The fields are only readable.
- Now you have configured the properties for the Approve Order User Task. To accommodate a scenario for the orderApproval group rejecting an order, you must add an end event to this User Task. Therefore this process can terminate at Approve Order User Task.
- To configure the Mail Task, do the following.
- Click on the Order Product Mail Task. In the Properties pane, select the General tab.
Id: mtOrderProduct
Name: Order Product
- Select the Main Config tab, and fill the respective fields (i.e., To, From, Subject).
- In the non-HTML field, enter “Order ${quantity} of ${productID} at the rate of ${unitPrice}”. The variable will be used to create the mail body.
- Click on the Order Product Mail Task. In the Properties pane, select the General tab.
To create the Business Archive File (.bar), do the following.
On the Explorer, found in the upper left of your screen, navigate to Package Explorer.
Right click on the package and select “Create deployment artifacts”.
Navigate to the location of the source. You will find the .bar file inside the deployment folder.