Tuesday, September 29, 2015

SOA 12c: How to add conditions based on fault data in fault-policies.xml

Little bit of back ground on Fault-policies.xml and fault-bindings.xml:
Fault Policy File contains differenct policies. Each policy Maps "conditions" to "Actions"
    "Conditions": Group of Faults or a single fault.
    "Actions": single action or Set of actions identified by and ID
Fault Bindings file maps Policies to applications/components/bindings.

In this example, we will see how to put a condition on the fault data the Client receives.

With in a single fault policy, for the same fault, we can add test conditions and trigger different actions based on the condition results. Below is a snippet for example.

 <faultName name="custom:InvalidCreditCard"
                       xmlns:custom="
http://xmlns.oracle.com/12cLearning/CCStatus/QueryCCStatusBpel"
                        xmlns:cs="
http://ns.example.com/ccstatus"
                       path="SOA\WSDLs\queryccstatusbpel_client_ep.wsdl">
            <condition>
                <test>$fault.payload/cs:faultReason="Date Expired"</test>
                <action ref="HumanIntervention"/>
                <!--action ref="ora-retry"/-->
            </condition>
                <condition>
                    <action ref="ora-retry"/>
                </condition>
</faultName>


You can make the condition based on the fault definition in the WSDL provider. for e.g. Fault: InvalidCreditCard is defined in the wsdl as below.
$fault.<wsdl Part Name>/<namespace>:<XPath As per Schema Definition>
Make sure <namespace> is added as shown in the above example.

<wsdl:fault name="InvalidCreditCard" message="client:QueryCCStatusBpelFaultMessage"/>

    <wsdl:message name="QueryCCStatusBpelFaultMessage">
        <wsdl:part name="payload" element="ns1:CCFault"/>
    </wsdl:message>


 

No comments:

Post a Comment