This documentation is for WSO2 Enterprise Integrator version 6.5.0 . View documentation for the latest release in the 6.x.x family and the latest release in the 7.x.x family.

All docs This doc
Skip to end of metadata
Go to start of metadata


This sample explains the functionality of <forEach/> construct, where, user can implement repetitive tasks. The tasks can be sequential or parallel based on parallel property. So <forEach/> becomes advantageous compared to <while/> or <repeatUntil/>, when the repetitive tasks are paralleled.

Introducing the ForEach Construct

                <from>concat($thisStartRequestMsg.body/text(), $ForEachCounter)</from>

In this sample, 3 iterations take place based on the values of <startCounterValue/> and <finalCounterValue/>. The property counterName can be used as a local variable inside the child scope to store current iteration value. In the above example, ForEachCounter variable value can be 1,2 or 3.

Then, inside <scope/>, repetitive task can be implemented.


<forEach/> can have only one <scope/> child.

Deploying the Sample

WSO2 BPS provides a sample, which can be deployed and executed to understand the ForEach constructs discussed above. Follow the instructions below to deploy and trigger the process.

1. Log in into BPS server management console and select "Processes -> Add" under the "Main" menu.

2. Upload the <EI_HOME>/samples/business-process/bpel/ directory.

3. In the "Deployed Processes" window, click the "Process ID" to access its "Process Information" window.

4. Under the "WSDL Details" widget, trigger the process using the "TryIt" link to create an instance of it.

  • No labels