How to implement FOR loop in BPEL process in SOA Suite 12C

In this article we will see how to implement FOR loop in BPEL process. Follow the below steps to print the series of numbers using for-each activity.

  1. Create a project under same application. Go to File -> New -> Project -> SOA Project. Enter project name ForEachDemo and then select Composite With BPEL Process in the next wizard
  2. Click on FINISH button and BPEL Process creation wizard will open. Enter BPEL process name and select Synchronous BPEL Process option as template type. Select the checkbox Expose as a SOAP service.FOR_EACH_BPEL_ACTIVITY_1
  3. Create two variables in the BPEL process. Click on Variable icon in the main scope. The variables will be a�� loopcounter and resultvar and variable type will be integer.FOR_EACH_BPEL_ACTIVITY_2 FOR_EACH_BPEL_ACTIVITY_3
  4. Select ASSIGN activity from component palette and drag and drop it in between receiveInput and replyOutput.FOR_EACH_BPEL_ACTIVITY_4
  5. Double click on Assign activity and map loopcounter value to input variableFOR_EACH_BPEL_ACTIVITY_5
  6. Select FOR-EACH activity from Structured Activities component and drag and drop it after Assign activity.FOR_EACH_BPEL_ACTIVITY_6 FOR_EACH_BPEL_ACTIVITY_7
  7. Double click on ForEach activity and enter counter name as loopcounter. Go to Counter Values tab and enter 1 as start value and input payload as target value.FOR_EACH_BPEL_ACTIVITY_8
  8. Drag and drop an ASSIGN activity within FOR-EACH activityFOR_EACH_BPEL_ACTIVITY_9
  9. Double click on assign activity and add an expression to the resultvar like below screenshotFOR_EACH_BPEL_ACTIVITY_10
  10. Now drag and drop another ASSIGN activity after FOR-EACH activityFOR_EACH_BPEL_ACTIVITY_11
  11. Map resultvar to output payload in the assign activityFOR_EACH_BPEL_ACTIVITY_12
  12. Save the project and the BPEL process will look like below screenshotFOR_EACH_BPEL_ACTIVITY_13
  13. Deploy the project and test it in EM console.
  14. Enter 5 as input string and see the result.FOR_EACH_BPEL_ACTIVITY_14 FOR_EACH_BPEL_ACTIVITY_15 FOR_EACH_BPEL_ACTIVITY_16

Leave a Reply

Your email address will not be published. Required fields are marked *

Show my latest post here