What Happens After You Create a Scope Activity

Using Fault Handling in a BPEL Process 11-33 assign invoke name=InvokeCheckCreditCard inputVariable=lCreditCardInput outputVariable=lCreditCardOutput partnerLink=CreditCardAuthorizationService portType=ns2:CreditAuthorizationPort operation=AuthorizeCredit switch name=Switch_EvaluateCCResult case condition=bpws:getVariableDatalCreditCardOutput,status, ns8:status = APPROVED bpelx:annotation bpelx:patternstatus lt;gt; approvedbpelx:pattern bpelx:annotation throw name=Throw_Fault_CC_Denied faultName=client:OrderProcessorFault case switch sequence scope

11.10.4 What You May Need to Know About Scopes

Scopes can use a significant amount of CPU and memory and should not be overused. Sequence activities use less CPU and memory and can make large BPEL flows more readable.

11.10.5 How to Use a Fault Handler Within a Scope

If a fault is not handled, it creates a faulted state that migrates up through the application and can throw the entire process into a faulted state. To prevent this from occurring, place the parts of the process that have the potential to receive faults within a scope. The scope activity includes the following fault handling capabilities: ■ The catch activity works within a scope to catch faults and exceptions before they can throw the entire process into a faulted state. You can use specific fault names in the catch activity to respond in a specific way to an individual fault. ■ The catchAll activity catches any faults that are not handled by name-specific catch activities. Example 11–25 shows the syntax for catch and catchAll activities. Assume that a fault named x:foo is thrown. The first catch is selected if the fault carries no fault data. If there is fault data associated with the fault, the third catch is selected if the type of the faults data matches the type of variable bar. Otherwise, the default catchAll handler is selected. Finally, a fault with a fault variable whose type matches the type of bar and whose name is not x:foo is processed by the second catch. All other faults are processed by the default catchAll handler. Example 11–25 Catch and CatchAll Activities faulthandlers catch faultName=x:foo empty catch catch faultVariable=bar empty catch catch faultName=x:foo faultVariable=bar empty catch 11-34 Oracle Fusion Middleware Developers Guide for Oracle SOA Suite catchAll empty catchAll faulthandlers

11.10.6 How to Create a Catch Activity in a Scope

To create a catch activity in a scope: 1. In the expanded Scope activity, click Add Catch. Figure 11–9 provides details. Figure 11–9 Add Catch This creates a catch activity in the right side of the scope activity.

2. Double-click the Catch activity.

3. Optionally enter a name.

4. To the right of the Namespace URI field, click the Search icon to select the fault.

5. Select the fault in the Fault Chooser dialog, and click OK.

The namespace URI for the selected fault displays in the Namespace URI field. Your fault selection also automatically displays in the Local Part field. Figure 11–10 provides an example of a Catch dialog. This example shows the selectionFailure catch activity of the Scope_AuthorizeCreditCard scope activity in the Fusion Order Demo application. This catch activity catches orders in which the credit card number is not provided. Using Fault Handling in a BPEL Process 11-35 Figure 11–10 Catch Dialog 6. Design additional fault handling functionality.

7. Click OK.

Figure 11–11 provides an example of two catch activities for the Scope_ AuthorizeCreditCard scope activity. The second catch activity catches credit types that are not valid. Figure 11–11 Catch Activities in the Designer

11.10.7 What Happens When You Create a Catch Activity in a Scope

Example 11–26 shows the catch activity in the .bpel file after design completion. The selectionFailure catch activity catches orders in which the credit card number is not provided and the InvalidCredit catch activity catches credit types that are not valid. Example 11–26 Catch Branch faultHandlers catch faultName=bpws:selectionFailure sequence assign name=Assign_noCCNumber copy from expression=stringCreditCardCheck - NO CreditCard to variable=gOrderProcessorFaultVariable part=code copy assign throw name =Throw_NoCreditCard