Java Reference
In-Depth Information
The <catch> activity can contain a variety of other constructs; for example, a <sequence>
allows you to do more than one thing inside the handler.
Each <catch> is intended to handle a single fault. There are three ways to associate a <catch>
with a fault type:
▪ Match the faultName and faultVariable type.
▪ Match a global variable by its faultName only (which must be a unique QName ).
▪ Match a global variable by its faultVariable type. In this case, it must refer to a WSDL
faultMessage type, or an XML schema element ( faultElement type).
It is best to match both the name and variable type, as this is the clearer and most specific
option. The BPEL engine will attempt to find the best match it can for a fault that has been
thrown in the current scope. If it can't find any match, the engine looks for a <catchAll> ;
if none is defined, the fault gets thrown to the default handler. You don't want to rely on the
default handler any more than you would in a Java program. Doing so is a lot like writing this:
public static void main(String... arg) throws Exception { ... }
Default fault handling
A fault handler is allowed two different types of children: <catch> and <catchAll> . The
<catchAll> construct is defined as a default handler for exceptions that you do not explicitly
name. You use the <catchAll> construct as a child of a <faultHandler> . You define this
construct at the end of a fault handler, usually after you have defined specific faults that you
explicitly want to catch.
Often a fault handler is defined within an <invoke> activity to catch any faults thrown during
the invocation of a given service. Such a construct looks like this:
<bpel:invoke inputVariable="aRequest"
operation="checkStock" outputVariable="aResponse"
partnerLink="myCartPartner" portType="cart:CartPortType">
<bpel:catchAll>
//...
</bpel:catchAll>
</bpel:invoke>
You can combine the two as well:
<bpel:invoke inputVariable="aRequest"
operation="checkStock" outputVariable="aResponse"
partnerLink="myCartPartner" portType="cart:CartPortType">
<catch faultName="CartFault"
faultVariable="CartFault">
Search WWH ::




Custom Search