BPEL structured activities: If-Else

Different from the Pick activity, BPEL If-Else executes the processes based on the a conditions instead of an event. We will see how it works with this simple tutorial. The process returns the string “Hello John” if the input is John, otherwise, it returns “You are not John”.

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

BPEL's If-Else activity

  1. Create a new BPEL project named “BPEL_IfElse” by selecting File→New→Others→BPEL 2.0→BPEL Project. Select Next. Type the project name as BPEL_IfElse and select the Target Runtime as Apache ODE 1.x Runtime. Click Finish.
  2. Create a new BPEL process file named IfElseSample by right clicking on the BPEL_IfElse/bpelContent folder, select New→Others→BPEL 2.0→New BPEL Process File. Click Next. Fill in BPEL Process Name the string IfElseSample, and in the Namespace the string http://ifelse.bpel.tps. Click Next.
  3. Select the Template as Synchronous BPEL Process and modify the Service Address as http://localhost:8080/ode/processes/IfElseSample (suppose that your Tomcat environment is running on port 8080). Click Finish.
  4. Open IfElseSampleArtifacts.wsdl. right click on IfElseSamplePort. Select show properties and make sure that the Address is http://localhost:8080/ode/processes/IfElseSample.
  5. Open IfElseSample.bpel file. Click and drag the If control from the Palette to the process, between the receiveInput and replyOutput actions.
  6. Drag an Assign action into the If and drag the replyOutput below the Assign. A sequence is automatically created.


  7. Right click on the If activity, select Add Else. Drag one Assign and one Reply action to the Else branch.


  8. Select the If activity, in the Properties view, select Details and edit the condition as $input.payload/tns:input=“John”.


  9. Click on the Assign action, in its Properties view, select Details→New. Assign the fix value “Hello John” to the variable output→payload→result. A pop-up dialog appears asking you about the variable initiation. Select Yes. In case the pop-up dialog does not appear, you can do the following steps to initialize the result variable: change the operation to “assign from a Variable to Variable”; then, assign the input variable to output→payload→result; the pop-up dialog should appear; then you change the operation back to “assign from a Fix value to a Variable”.


  10. By the same way, at the Assign1 action, assign “You are not John” to the output-payload-result. Remember to initialize the variable result before assigning this string.
  11. Click on the Reply action, in the Detail tab, at the Quick Pick, select IfElseSample→process→IfElseSampleResponseMessage-Payload→result to assign the result to the output variable.


  12. Save the process design. Right click on the BPEL_IfElse/bpelContent, select New→Others→BPEL 2.0→Apache ODE Deployment Descriptor. Click Next. Verify the BPEL Project name as /BPEL_IfElse/bpelContent. Click Finish.
  13. Open the deploy.xml file. And select the Associated port with the Partner Link client is IfElseSamplePort.
  14. Save file and open the Server view, right click on the Ode v1.x Server at localhost, select Add and Remove Projects. Select the BPEL_IfElse in the Available projects box and click Add. Then, click Finish.
  15. 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:


  16. Done.

Exercices

  1. Create a BPEL process using If activity to find the maximum of two integers.
  2. Create a BPEL process using If activity to sort three integer in ascending order.
teaching_assistant/bpel/bpel_structured_activities_-_if-else.txt · Last modified: 2014/04/14 09:15 by IT Courses (NNC)
Back to top
CC Attribution-Share Alike 4.0 International
chimeric.de = chi`s home Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0