You need to repeat the execution of some activity until a condition fails, as in a loop.
Select from one of the available BPEL constructs for this purpose:
These constructs are rather straightforward, so we’ll just take a quick tour.
As in Java, the
<while> activity allows you
to repeat a block of code (or, more specifically, the BPEL activity
you’re enclosing) until a certain
longer evaluates to true.
Here is the basic structure:
<while> <condition>$lineItems < 10</condition> <scope>...</scope> </while>
A slightly more ambitious example illustrates how you can increment a variable counter within a loop:
<while> <condition>$counter < $lineItems</condition> <sequence> <invoke partnerLink="CheckInventory" ... /> <!–- Here we increment the condition's counter--> <assign> <copy> <from expression="$counter + 1" /> <to variable="counter" /> </copy> </assign> </sequence> </while>
This all behaves just as you would expect. If the condition is not true the first time it is evaluated, the activity it contains will never be executed.
repeatUntil loop acts like a do/while loop in Java. That is, its primary
distinguishing feature is that it always executes at least once, as
the condition is evaluated after the enclosed activity has been run.
Its structure looks like this:
<repeatUntil> <some activity /> <condition> boolean expression </condition> </repeatUntil>
Here is the previous example ...