BPEL Example

In this post we will create one more BPEL example. In the earlier HelloWorld example we have created a xsd file first and used it in the BPEL process. But we can also generate the xsd file while creating the bpel process. ie. BPEL process automatically creates a xsd file if you don't specify any existing file.

Lets create a simple BPEL process to calculate length of a input string.
We will send some string as input to the BPEL and it will calculate and returns the length of it.

This example includes 4 steps:

  1. Creating a SOA application and project
  2. BPEL creation
  3. Deploy the project
  4. Testing the project



1. Creating  a SOA application and project:

You can create a new SOA application and project by referring below old post
Create SOA Application and Project
Created StringLengthSoaApplication & StringLengthSoaProject

2. BPEL Creation :

Let's create a new BPEL process which returns string length.
1. Open StringLengthSoaProject (composite.xml) file.

2. Right click on the StringLengthSoaProject (Composite.xml) file --> Insert -->BPEL process.

3. Give a name for BPEL process, select "Synchronous BPEL process" and keep the remaining fields as it is with default values. Click on OK

4.  It will generate 3 files. BPEL process file, xsd file and wsdl file

5. In the generated xsd file you can observe both input and result are String types.

6. Open the BPEL file. Drag and drop Assign component between receiveInput and callbackClient.

7. Open Assign component by double clicking on it. Drag and drop Expression component on the result variable.

8. Expression builder dialog box opens. In the expression field add below expression to calculate length of a string.
concat('The Length is : ', string-length($inputVariable.payload/client:input))

I have used concat() & string-length() functions in the "string functions" section to in the above expression.
Click on OK.

9. Click on Apply and OK buttons on the "Edit Assign" dialog.

10. Save all your changes. BPEL has been created successfully.

3. Deploy the project :

Deploy the project by following below post.
After successfully deployed the project, you can test the flow.

4. Testing the project:

Test the deployed project by following below post.
Testing SOA project

Request: 

Response: