Listing 1 Sample excerpt showing dynamic ?parallelism with <forEach>

<forEach parallel="yes" counterName="n">
   <startCounterValue>1</startCounterValue>
   <finalCounterValue>count($order/lineItem)</finalCounterValue>

   <scope name="reserveInventoryItem">
      <!-- variables, partnerLinks defined here are local to each iteration -->

      <partnerLinks>
         <partnerLink name="vendorPL" .../>
      </partnerLinks>
  
      <variables>          ...      </variables>

      <sequence>
         <assign>
            <copy>
               <from>$order/lineItem[$n]/vendor/sref:service-ref</from>
               <to partnerLink="vendorPL" />
            </copy>
            ...
         </assign>

         <invoke name="reserveInventory" partnerLink="vendorPL" .../>
         <receive name="inventoryReserved" partnerLink="vendorPL" .../>

	  ...

         <assign>
            <copy>
               <from>$reservationResult</from>
               <to>$order/lineItem[$n]/reservationResult</to>
            </copy>
         </assign>
      </sequence>
   </scope>
</forEach>

Listing 2 Example excerpt of change handling

   <eventHandlers>
      <onEvent operation="modifyDeliverySchedule" 
	   messageType="ns:DeliveryPreferences" ...>
         <correlations>
            <correlation set="orderId" ... />
            <correlation set="customerId" ... />
         </correlations>
         <scope>
               ...
               <invoke name="updateDelivery" partnerLink="deliveryPL" .../>
               ...
         </scope>
      </onEvent>
   </eventHandlers>

Listing 3 Excerpt showing fault handling and compensation

<scope name="main">

   <!-- If we fail to reserve all inventory, undo the inventory we
        already reserved and back out the payment processing -->

   <faultHandlers>
      <catch faultName="ns:cannotReserveFault" ...>
          <sequence>
             <compensateScope target="reserveInventory" />
             <compensateScope target="processPayment"/>
             ...
             <invoke partnerLink="clientPL" operation="orderCancelled" .../>
             <rethrow/>
           </sequence>
      </catch>
   </faultHandlers>

   ...

   <sequence>
      ...
      <scope name="processPayment">

        <!-- This scope processes credit card payments. The compensation
             handler for it undoes its work - here reversing the charge.
             Note the BPEL engine will maintain variables' values for the
             purpose of compensation -->

        <variables>
           <variable name="chargeRequest" .../>
           <variable name="chargeResponse" .../>
         </variables>

         <compensationHandler>
             <invoke name="reverseCharge" 
                 inputVariable="chargeResponse" .../>
         </compensationHandler>
         <sequence> 
             ...
         	<invoke name="chargeCard" 
                 inputVariable="chargeRequest"
                 outputVariable="chargeResponse"
                 ... />
         </sequence>
      </scope>
      
      <!-- Here we reserve the inventory. If it doesn't succeed within 24
           hours, the fault we throw will be caught above and cause the
           compensation logic to release the inventory and reverse charges -->

      <scope name="reserveInventory">
         <eventHandlers>
            <onAlarm>
                <for>"P24H"</for>   <!-- P24H == "24 hour period" -->
                ...
                <throw faultName="ns:cannotReserveFault" .../>
                ...
            </onEvent>
         </eventHandlers>

         <forEach ...>
            ...
            <scope name="reserveInventoryItem">
                ...
                <compensationHandler>
                    <invoke name="releaseInventory" ... />
                </compensationHandler>
                <sequence>
                  ...
                  <invoke name="reserveInventory" ... />
                  <receive name="inventoryReserved" ... />
                  <if> 
                 	<condition>
                      not($reservationResult/status='success')
                    </condition> 
              	<throw faultName="ns:cannotReserveFault" .../> 
                  </if>
                  ...
                </sequence>
      </scope>
         </forEach>

      </scope>
   </sequence>
</scope>