Java Reference
In-Depth Information
Handling Faults
Problem
You want to gracefully handle exceptions that are thrown during the execution of a partner
web service within your process.
Solution
Use a <faultHandlers> container and its associated <catch> or <catchAll> constructs.
Discussion
You can't always assume that everything will go according to plan with a composite service
process. Just as you would use exception handling within Java, BPEL makes available certain
constructs that allow you do to cleanup work when an exception is thrown during the exe-
cution of your process. Using fault handlers is intuitive and simple. Catching faults is very
similar to catching exceptions in Java except that you needn't define an associated try . Fault
handlers can be declared globally across an entire process, within a scope, or directly on an
<invoke> activity.
Fault handlers are made available immediately upon initialization of the scope to which they
are attached. If a fault occurs during processing of the attached scope (even if there is no form-
al scope declared and the implicit global scope is used), the error will be propagated to the
associated fault handler. Faults are initialized within a BPEL process if the associated WSDL
operation returns a fault message. Faults can also be thrown by the BPEL process itself, such
as in the event that some complex construct (such as a <join> ) fails, or a network failure oc-
curs.
Here is the basic construct to define a global fault handler (that is, one that is not associated
with a more specific, explicitly defined scope):
<variables>
<variable name="CartFault"
messageType="pos:cartFaultType"></variable>
</variables>
<faultHandlers>
<catch faultName="CartFault"
faultVariable="CartFault">
//...handle with an activity, such as <reply> to caller
Search WWH ::




Custom Search