What Happens When You Create a forEach Activity
The following example shows the .bpel
file after design is complete for a sequential forEach
activity.
<faultHandlers> <catch faultName="bpel:invalidBranchCondition"> <sequence> <assign> <copy> <from>'invalidBranchCondition happened'</from> <to>$output.payload</to> </copy> </assign> <reply name="replyOutput" partnerLink="client" portType="tns:Test" operation="process" variable="output"/> </sequence> </catch> </faultHandlers> <sequence> <!-- pick input from requester --> <receive name="receive" createInstance="yes" partnerLink="client" portType="tns:Test" operation="process" variable="input"/> <assign> <copy> <from>3</from> <to>$request.payload</to> </copy> <copy> <from>''</from> <to>$output.payload</to> </copy> </assign> <forEach counterName="i" parallel="no"> <startCounterValue>$input.payload/tns:startCounter+1</startCounterValue> <finalCounterValue>$input.payload/tns:finalCounter+1</finalCounterValue> <completionCondition> <branches>$input.payload/tns:branches+1</branches> </completionCondition> <scope name="scope1"> <partnerLinks> <partnerLink name="DummyService" partnerLinkType="tns:DummyService" myRole="DummyServiceClient" partnerRole="DummyServiceProvider"/> </partnerLinks> <sequence> <assign> <copy> <from>concat($output.payload, $i, 'A')</from> <to>$output.payload</to> </copy> </assign> <invoke name="invokeDummyService" partnerLink="DummyService" portType="tns:DummyPortType" operation="initiate" inputVariable="request"/> <receive name="receiveFromDummyService" partnerLink="DummyService" portType="tns:DummyCallbackPortType" operation="onResult" variable="response"/> <assign> <copy> <from>concat($output.payload, $i, 'B')</from> <to>$output.payload</to> </copy> </assign> </sequence> </scope> </forEach> <!-- respond output to requester --> <reply name="replyOutput" partnerLink="client" portType="tns:Test" operation="process" variable="output"/> </sequence>
The following example shows the .bpel
file after design is complete for a parallel forEach
activity.
<sequence> <!-- pick input from requester --> <receive name="receive" createInstance="yes" partnerLink="client" portType="tns:Test" operation="process" variable="input"/> <assign> <copy> <from>$input.payload/tns:value1</from> <to>$request.payload</to> </copy> <copy> <from>''</from> <to>$output.payload</to> </copy> </assign> <forEach counterName="i" parallel="yes"> <startCounterValue>($input.payload/tns:value1 + 1)</startCounterValue> <finalCounterValue>($input.payload/tns:value2 + 2)</finalCounterValue> <scope name="scope1"> <partnerLinks> <partnerLink name="DummyService" partnerLinkType="tns:DummyService" myRole="DummyServiceClient" partnerRole="DummyServiceProvider"/> </partnerLinks> <sequence> <assign> <copy> <from>concat($output.payload, 'A')</from> <to>$output.payload</to> </copy> </assign> <invoke name="invokeDummyService" partnerLink="DummyService" portType="tns:DummyPortType" operation="initiate" inputVariable="request"/> <receive name="receiveFromDummyService" partnerLink="DummyService" portType="tns:DummyCallbackPortType" operation="onResult" variable="response"/> <assign> <copy> <from>concat($output.payload, 'B')</from> <to>$output.payload</to> </copy> </assign> </sequence> </scope> </forEach> <!-- respond output to requester --> <reply name="replyOutput" partnerLink="client" portType="tns:Test" operation="process" variable="output"/> </sequence>