Tuesday, January 21, 2014

Develop Simple BPEL Process

Overview

This post describes how we can develop simple BPEL process using WSO2 Developer studio and deploy and run it on WSO2 BPS server. Process will take your name as input and output with "Hello: " and your name.

Prerequisites 

To get basic idea about BPEL just read my previous post What is BPEL.
You need to download
  1. WSO2 Developer studio 3.0.0/3.5.0
  2. WSO2 BPS server 3.1.0

How

Developer studio is a complete Eclipse-based SOA development environment .So you can start it just like normal eclipse IDE.
1) You can create BPEL work flow in two ways.

Click on File>>New>>Other and Select WSO2>> Business Process >> BPEL Workflow

Or Click on Developer studio>> Open Dashboard>>BPEL Workflow
2) Click create New BPEL Workflow


3) Give meaningful name for your process.
there are Three Templates you can select

  1. Synchronous normal one way calls
  2. Asynchronous when we have call back service,Human-task related processes and long running asynchronous processes
  3. Empty


Since we develop simple hello process select Synchronous template



4) Click Next

5) Then You can see your project structure as below

  1. deploy.xml-contain deployment information like ports and internal and external interfaces we link through our business process 
  2. HelloWorldProcess.bpel-BPEL model 
  3. HelloWorldProcess.bpelex-Extentions to BPEL model file
  4. HelloWorldProcessArtifacts.bpel -WSDL file of web services including BPEL process
  5. pom.xml- build file for WSO2 archive


6) Double click on .BPEL file. You can  see following auto generated BPEL flow.

7) Open BPEL design Palette from click on small triangle in right side of the IDE. If it is not visible you may need to reset perspective by click on Window>>Reset Perspective .Make sure you have open BPEL file.

 
8) Palette can be seen as below once you click on triangle icon.


You can see different UI components for BPEL actions,controls in palette menu.Right click on FIX_ME-Add_Business_Logic_Here  and Delete .

Now we need to get input string and con cat with "Hello: " string. Then we assign it to Output variable. We need assign action for that. by modifying Assign properties we can do the concatenation.

9) Drag Assign Action from Palette middle of receive input and reply output actions. It can be done by Right click on BPEL model >> Inset Before>>Assign too.
Final BPEL work flow should be seen as follows.

10) Click on Assign action and select properties from the menu which is just under the model .Click New. Select Expression from first combo box and Select variable from second combo box.
Write following expression on FROM: text window.
concat("Hello: ",$input.payload/tns:input)

11) Select Output/payload/result in TO: window.

12) Click save. Click Yes when ask to initialize variables.

13) Now we have finished modelling process. To deploy our process we need to do some configurations in deploy.xml.
Click on deploy.xml  and Select HelloworldProcessPort from first row of Inbound Interfaces table under associate port. Select Relate service.(You will have only one option to select).We do not have outbound interface since we do not connect to outer web services.

deploy.xml designer view should be look like this.(Right click on deploy.xml and select ODE deployment Descriptor Editor for following view.)
14) Now we have finished Developing out first BPEL process.Right Click on HelloWorldProcess and click export.click Deploy able WSO2 Archive.

15) Browse appropriate location to save your BPEL process as zip file.


How to Deploy

1) Unzip WSO2 BPS server. go to bin and run sh wso2server.sh command to start the server.
In the console window you can see the server Management console URL. Paste URL in your browser and Login to Management console .
Mgt Console URL  : https://localhost:9443/carbon/
Username:admin
password:admin
2) Go to processes and click Add. Browse your zip file by clicking on choose file and click on Upload. wait few seconds. click on List view.
3) Click on Process ID link of Your HelloworldProcess
4) Click on Try it.
Add your name as input of request.
<body>
   <p:HelloWorldProcessRequest xmlns:p="http://wso2.org/bps/sample">
      <!--Exactly 1 occurrence-->
      <input xmlns="http://wso2.org/bps/sample">Waruna</input>
   </p:HelloWorldProcessRequest>
</body>
click send
Response will look like this.

<HelloWorldProcessResponse xmlns="http://wso2.org/bps/sample">
   <tns:result xmlns:tns="http://wso2.org/bps/sample">Hello: Waruna</tns:result>
</HelloWorldProcessResponse>



Congratulation..!!! Your BPEL is process working successfully.

Next

I like to discuss some important concepts in BPEL in my next post.

No comments :

Post a Comment