Guidelines for BPEL Catch and Catch-All Blocks in Synchronous Request-Response

24-8 Developers Guide for Oracle Application Integration Architecture Foundation Pack

24.4.2 Guidelines for BPEL Catch and Catch-All Blocks in Synchronous Request-Response

Each BPEL process should have explicit catch blocks for remote faults, binding faults, business faults Oracle AIA faults, and any other fault expected on a partner link at design time. Use these guidelines for defining these catch blocks.

24.4.2.1 Handling Business Faults

To handle an internal business fault: 1. In the case of a BPEL process carrying out a throw activity, construct a business fault message Oracle AIA fault message and populate the AIA Fault message with the ECID, as shown in Example 24–8 . Example 24–8 Business Fault Message sequence name=SequenceBusinessFault assign name=AssignBusinessFault copy from expression=ora:processXSLTxslEBM_to_Fault.xsl,bpws: getVariableDataEBM_HEADER to variable=AIAFaultMessage part=AIAFault query=corecom:Fault copy copy from expression=invalid account id to variable=AIAFaultMessage part=AIAFault query=corecom:Fault corecom:FaultNotificationcorecom:FaultMessagecorecom:Text copy copy from expression=invalid account id to variable=AIAFaultMessage part=AIAFault query=corecom:Fault corecom:FaultNotificationcorecom:FaultMessagecorecom:Stack copy copy from expression=ora:getInstanceId to variable=AIAFaultMessage part=AIAFault query=corecom: Faultcorecom:FaultNotificationcorecom:FaultingServicecorecom: InstanceID copy copy from expression=BPEL to variable=AIAFaultMessage part=AIAFault query=corecom:Fault corecom:FaultNotificationcorecom:FaultingServicecorecom: ImplementationCode copy copy from expression=ora:getCompositeName to variable=AIAFaultMessage part=AIAFault query=corecom: Faultcorecom:FaultNotificationcorecom:FaultingServicecorecom:ID copy copy from expression=ora:getECID to variable=AIAFaultMessage part=AIAFault query=corecom:Fault corecom:FaultNotificationcorecom:FaultingServicecorecom: ExecutionContextID assign throw name=Throw_custom_business_fault faultName=client:fault faultVariable=AIAFaultMessage sequence Configuring Oracle AIA Processes for Error Handling and Trace Logging 24-9 2. Catch the preceding fault message in the catch block. In the catch block: ■ Send the AIA Fault Message as a reply. Invoke the AIAAsyncErrorHandlingBPELProcess with this Oracle AIA fault message as input. ■ Throw the AIA Fault Message that has been caught. This rethrow enables the process to appear as faulted in the Enterprise Manager Console. To handle an external business fault: In the case of an Invoke activity in the BPEL receiving an AIA fault message as a response, catch the AIA fault message in the catch block. In the catch block: ■ Send the AIA Fault Message as reply. ■ Throw the AIA Fault Message that has been caught. This rethrow enables the process to appear as faulted in the Oracle Enterprise Manager Console.

24.4.2.2 Handling Run-time Faults Defined in the Fault Policy File

For each of the run-time faults that has been defined in the fault policy xml file, have a catch block in the BPEL. To handle run-time faults defined in the fault policy file: 1. In the catch block, construct an Oracle AIA fault message. 2. Send this Oracle AIA fault message as the reply. 3. Rethrow the fault that has been caught. This will enable the process to appear as faulted in the Oracle BPEL Console.

24.4.2.3 Handling Run-time Faults Not Defined in the Fault Policy File

Each BPEL process should also have a catch-all block to process run-time faults that are not caught in catch-blocks and not defined in the fault policy file. To define the catch-all block: 1. Construct an Oracle AIA fault message. Populate the AIA Fault message with ECID as shown in Example 24–9 . Example 24–9 Catch-All Block Construction sequence name=SequenceCatchAll assign name=AssignFault Note: Ensure that in EBM_to_Fault.xsl, the corecom:ExecutionContextID element is injected under the corecom:FaultingService element. Note: In this case, we do not invoke the AIAAsyncErrorHandlingBPELProcess because the business fault is already handled by the Oracle Fusion Middleware Fault Management Framework, according to the fault polices defined in the associated fault policy file. 24-10 Developers Guide for Oracle Application Integration Architecture Foundation Pack copy from expression=ora:processXSLTxslEBM_to_Fault.xsl,bpws: getVariableDataEBM_HEADER to variable=AIAFaultMessage part=AIAFault query=corecom:Fault copy copy from expression=ora:getFaultAsString to variable=AIAFaultMessage part=AIAFault query=corecom:Fault corecom:FaultNotificationcorecom:FaultMessagecorecom:Text copy copy from expression=ora:getFaultAsString to variable=AIAFaultMessage part=AIAFault query=corecom:Fault corecom:FaultNotificationcorecom:FaultMessagecorecom:Stack copy copy from expression=ora:getCompositeInstanceId to variable=AIAFaultMessage part=AIAFault query=corecom:Fault corecom:FaultNotificationcorecom:FaultingServicecorecom: InstanceID copy copy from expression=BPEL to variable=AIAFaultMessage part=AIAFault query=corecom:Fault corecom:FaultNotificationcorecom:FaultingServicecorecom: ImplementationCode copy copy from expression=ora:getProcessId to variable=AIAFaultMessage part=AIAFault query=corecom:Fault corecom:FaultNotificationcorecom:FaultingServicecorecom:ID copy copy from expression=ora:getECID to variable=AIAFaultMessage part=AIAFault query=corecom:Fault corecom:FaultNotificationcorecom:FaultingServicecorecom: ExecutionContextID assign sequence 2. Invoke the AIAAsyncErrorHandlingBPELProcess with this Oracle AIA fault message as input. 3. Send this Oracle AIA fault message as the reply. 4. Throw AIA fault message. This will enable the process to appear as faulted in the Oracle Enterprise Manager Console. 5. Unless otherwise required, these catch and catch-all blocks can be defined at the top-level scope and do not need to be defined at the scope for each partner link. For more information about the Fault Management Framework, see Using the Fault Management Framework in Oracle Fusion Middleware Developers Guide for Oracle SOA Suite. Note: Ensure that in EBM_to_Fault.xsl, the corecom:ExecutionContextID element is injected under the corecom:FaultingService element. Configuring Oracle AIA Processes for Error Handling and Trace Logging 24-11

24.4.3 Guidelines for Configuring Mediator for Handling Business Faults