How To: Throw a custom fault/ exception in BPEL (SOA-Fault Handling)

Fault Handling in SOA is analogous to Exception Handling in OOPs. Below is how to throw a fault in a BPEL process:

1 - Define the fault message type

Add the RuntimeFault.wsdl to the Project/SOA/WSDLs folder. This WSDL contains the message definition of the fault that will be thrown at runtime.

<?xml version="1.0" encoding="UTF-8" ?>
<definitions name="RuntimeFault" targetNamespace="http://schemas.oracle.com/bpel/extension"
             xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/">
    <message name="RuntimeFaultMessage">
        <part name="code" type="xsd:string"/>
        <part name="summary" type="xsd:string"/>
        <part name="detail" type="xsd:string"/>
    </message>
</definitions>

2 - Define the fault variable to hold the fault

Define a new BPEL variable with the message type "RuntimeFaultMessage" created in the step above.

Variable Name: faultVar
Type: Message Type
Namespace: http://schemas.oracle.com/bpel/extension
Local Part: RuntimeFaultMessage

3 - Create a throw activity

Drag and Drop the "Throw" activity from the Components Menu into your BPEL process.

Activity Name: ThrowFault
Namespace: <Target Namespace of your BPEL process>
Local Part: <Name the Fault>
Fault Variable: faultVar (fault variable created in the step above)



Hope you find this information useful.Please share your feedback below. I would love to hear from you.

CaptiveCode