Table of Contents

BPEL structured activities: While

BPEL provides two repetitive execution actions which are While and Repeat Until. In this tutorial, we will see how the While works by a simple example, which returns five times the input string.

Tools: Eclipse 3.6, BPEL Designer 0.5.0 Plugin, Tomcat 7.0.53, ODE 1.3.5

BPEL's While loop

  1. Create a new BPEL project named “BPEL_While” by selecting File→New→Others→BPEL 2.0→BPEL Project. Select Next. Type the project name as BPEL_While and select the Target Runtime as Apache ODE 1.x Runtime. Click Finish.
  2. Create a new BPEL process file named WhileSample by right clicking on the BPEL_While/bpelContent folder, select New→Others→BPEL 2.0→New BPEL Process File. Click Next. Fill in BPEL Process Name the string WhileSample, and in the Namespace the string http://while.bpel.tps. Click Next.
  3. Select the Template as Synchronous BPEL Process and modify the Service Address as http://localhost:8080/ode/processes/WhileSample.
  4. Open WhileSampleArtifacts.wsdl. Right click on OpenSamplePort. Select show properties and make sure that the Address is http://localhost:8080/ode/processes/WhileSample.
  5. Open WhileSample.bpel file. Click and drag the While control from the Palette to the process, between the receiveInput and replyOutput actions. Drag an Assign action before the While activity, an Assign into the While and another Assign before the replyOutput.


  6. At the Variables view, click on the Add(+) symbol to add a new variable. Name it as iterator and add another variable named temp.


  7. Click on the variable iterator, in the Properties view, select Details→Browse. Select the type of this variable is {http://www.w3.org/2001/XMLSchema}integer. Keep the Namespace mapping as ns1. Select Ok.


  8. Select the variable temp and set its type as ns1:string.
  9. Click on the Assign action, in its Properties view, select Details→New. Assign the fix value 0 to the variable iterator.


  10. Then, select New again to assign the variable input→payload→input to temp.
  11. Select the While loop action. In the Details of its Properties, set the condition of the while loop as $iterator<5.


  12. At the Assign1 action, assign the expression $iterator+1 to the iterator.


  13. Click New again to add another expression which assign concat($temp,“ ”,$input.payload/tns:input) to the variable temp.


  14. Click on the Assign2 action, assign the variable temp to output→payload→result.
  15. Save the process design.
  16. Save the files. Right click on the BPEL_While/bpelContent folder, select New→Others→BPEL 2.0→Apache ODE Deployment Descriptor. Click Next. Verify the BPEL Project name as /BPEL_While/bpelContent. Click Finish.
  17. Open the deploy.xml file. And select the Associated port with the Partner Link client is WhileSamplePort.
  18. Save the file and open the Server view, right click on the Ode v1.x Server at localhost, select Add and Remove Projects. Select the BPEL_While in the Available projects box and click Add. Then, click Finish.
  19. Start the ODE server and use the Eclipse's Web Services Explorer to test our application. If you deploy the process successfully, you will see the result like the following:


  20. Done.

Exercices

  1. Create a BPEL process using While activity to find the factorial of an integer, which is n!=1*2*3*…*n.
  2. Create a BPEL process using While activity to find the nth Fibonaci number. Remind that: F(n)=F(n-1)+F(n-2) and F(1)=F(0)=1.