In the Condition field, enter a condition, as shown in

10-8 Oracle Fusion Middleware Developers Guide for Oracle SOA Suite fromValue is greater than zerofrom tooutput.payloadto copy assign copy fromValue is greater than zerofrom tooutput.payloadto copy assign -- switch depends on the input value field -- if conditioninput.payload 0condition extensionActivity bpelx:exec name=Java_Embedding version=1.5 language=java System.out.printlnif condition is true.\n; bpelx:exec extensionActivity elseif conditionbpws:getVariableDatainput, payload lt; 0condition assign copy fromValue is less than zerofrom tooutput.payloadto copy assign elseif else assign copy fromValue is equal to zerofrom tooutput.payloadto copy assign else if -- respond output to requestor -- reply name=replyOutput partnerLink=client portType=tns:Test operation=process variable=output sequence

10.3 Creating a While Activity to Define Conditional Branching

Another way to design your BPEL code to select between multiple actions is to use a while activity to create a while loop. The while loop repeats an activity until a specified success criteria is met. For example, if a critical web service is returning a service busy message in response to requests, you can use the while activity to keep polling the service until it becomes available. The condition for the while activity is that the latest message received from the service is busy, and the operation within the while activity is to check the service again. Once the web service returns a message other than service busy, the while activity terminates and the BPEL process service component continues, ideally with a valid response from the web service.

10.3.1 How To Create a While Activity

To create a while activity: 1. In the Component Palette, expand BPEL Constructs. Using Conditional Branching in a BPEL Process 10-9

2. Drag a While activity into the designer.

3. Click the + sign to expand the while activity. The while activity has icons to allow you to build condition expressions and to validate the while definition. It also provides an area for you to drag an activity to define the while loop.

4. Drag and define additional activities for using the while condition into the Drop

Activity Here area of the While activity for example, a Scope activity. The activities can be existing or new activities. 5. Press Ctrl+Space to invoke the XPath Building Assistant or click the XPath Expression Builder icon to open the Expression Builder dialog. 6. Enter an expression to perform repeatedly, as shown in Figure 10–10 . This action is performed until the given boolean while condition is no longer true. In this example, this activity is set to loop while less than 5. Figure 10–10 While Activity with an Expression

7. Click OK when complete.

10.3.2 What Happens When You Create a While Activity

Example 10–4 provides an example of the .bpel file after design completion. The while activity includes a scope activity. The scope activity includes invoke, assign, and wait activities. Database exception handling tasks are performed by creating a local variable and placing the invoke activity inside the scope activity. The local variable is set to false represented by 0. You attempt to call the external partner service in the while loop activity until the local variable is satisfied set to 1. The while activity is set to loop a maximum of five times. In the case of an exception, you reset the flag to false 0. Example 10–4 While Activity while name=While_1 condition=bpws:getVariableDatadbStatus 5 scope name=Scope_1 faultHandlers catchAll