Designer > Fault Handling > Catching Undeclared and SOAP Faults
  

Catching Undeclared and SOAP Faults

In standard fault handling, a fault message is declared as part of a WSDL operation. This declaration is a best practice and is expected behavior for BPEL fault handling. However, best practices do not always exist for Web services, and fault messages can be missing. When a service faults, the process faults with no information about the cause. To improve upon this behavior, Process Developer provides fault handling for undeclared faults.
To catch undeclared faults as well as SOAP faults, you can declare your own faults and then use the Process Developer fault custom functions to handle non-WSDL faults.
Using the Process Developer custom functions, you can prevent a process from terminating and can get access to the following fault information:
Here are some examples of how to create fault handling of undeclared faults.
Example 1: Add a CatchAll handler for undeclared faults and SOAP faults
  1. 1. Add a catchAll to a scope or to the process, as described in Defining Catch and CatchAll Fault Handlers. (Or add the handler as a BPMN boundary event).
  2. 2. Add an assign activity as the target activity of the handler.
  3. 3. Copy an expression to a process variable using the fault custom functions, as shown in the following example:
  4. 4. The copy operation you create would look like the following XQuery example:
  5. Copy From:
    <ns1:myFaultInfo xmlns:ns1="urn:faults:undeclared" xmlns:ns2="urn:faults:undeclared:result">
    <ns2:result>
    <ns2:FaultCode>{abx:getFaultCode()}</ns2:FaultCode>
    <ns2:FaultString>{ abx:getFaultString() }</ns2:FaultString>
    <ns2:FaultDetail>{ abx:getFaultDetail() }</ns2:FaultDetail>
    <ns2:SOAPFault>{ abx:getSOAPFault() }</ns2:SOAPFault>
    </ns2:result>
    </ns1:myFaultInfo>
    Copy To:
    myFaultInfo
Example 2: Declare a process variable to add to a catch
  1. 1. Add a schema element to a project WSDL. This is used in a catch or throw fault variable definition. For example:
  2. <xs:element name="undeclaredFaultElement" type="tns:undeclaredFaultType"/>
    <xs:complexType name="undeclaredFaultType">
    <xs:sequence>
    <xs:element name="faultMessage" type="xs:string" />
    </xs:sequence>
    </xs:complexType>
  3. 2. Add a catch and use the schema element as a Fault Variable Definition:
  4. Element = ns1:undeclaredFaultElement
  5. 3. Add a catch Fault Variable Name, such as myFault
  6. 4. Add an assign activity to the catch, and complete it as in Example 1.
Example 3: Declare a process variable to add to a throw activity
  1. 1. Add a schema element to a project WSDL, as in Example 2.
  2. 2. Add a new process variable, such as myFault, defined as the schema element.
  3. 3. Add an Initial Value to the variable as a literal, such as the following example:
  4. <ns1:undeclaredFaultElement xmlns:ns1="urn:faults:undeclared">
    <faultMessage>string</faultMessage>
    </ns1:undeclaredFaultElement>
  5. 4. Add a throw to the process.
  6. 5. Select myFault as the Fault Variable.
  7. 6. Create a Custom Fault Name for the throw, such as ns1:myFault.
Example 4: Catch a Java fault by name
  1. 1. Add the required namespace to the process, as follows:
  2. aex="http://www.active-endpoints.com/2004/06/bpel/extensions/"
    This is the Process Developer namespace used for catching system errors.
  3. 2. Add a catch to the process.
  4. 3. Define a custom Fault Name as follows:
  5. 4. Complete the catch by adding an assign. See Example 1.
  6. 5. For example, if the java.net.UnknownHostException is thrown by an invoke due to an invalid URL, the fault detail element will appear as follows:
  7. <ext:UnknownHostException xmlns:ext="http://www.active-endpoints.com/2004/06/bpel/extensions/"
    xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <Class xmlns="http://www.active-endpoints.com/2004/06/bpel/extensions/">java.net.UnknownHostException</Class>
    <Message xmlns="http://www.active-endpoints.com/2004/06/bpel/extensions/">unknown-host</Message>
    <StackTrace xmlns="http://www.active-endpoints.com/2004/06/bpel/extensions/">java.net.UnknownHostException: unknown-host
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:177)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
    at java.net.Socket.connect(Socket.java:525)
    at java.net.Socket.connect(Socket.java:475)
    at java.net.Socket.<init>(Socket.java:372)
    ...
    at org.activebpel.work.AeDelegatingWork.run(AeDelegatingWork.java:62)
    at org.activebpel.work.AeExceptionReportingWork.run(AeExceptionReportingWork.java:58)
    at org.activebpel.work.AeWorkerThread.run(AeWorkerThread.java:142)
    </StackTrace>
    </ext:UnknownHostException>