Thursday 11 July 2013

FAULT HANDLING : SCHEMA VIOLATED INPUT FILES

PROBLEM STATEMENT:
------------------
Schema violated input files are not moved to other directories as specified
in fault-policies.xml

In SOA Suite 11.1.1.5.0, customer has the following scenario where he wants
messages that are non compliant with xml schema be written to a file.

File Adapter Read -> BPEL -> File Adapter Write

The inbound file adapter has 'validateXML' set to true.
When a message is read that is not in compliance with xml schema, BPEL throws
'bpelx:invalidVaraibles' which is NonRecoverable System fault.

In fault-policies.xml, they have writeToFile action defined.

----------------------
<?xml version='1.0' encoding='UTF-8'?>
<faultPolicies xmlns="http://schemas.oracle.com/bpel/faultpolicy">
<faultPolicy version="1.0" id="AsyncFireForgetFaultPolicy"
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns="http://schemas.oracle.com/bpel/faultpolicy"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Conditions>
<faultName xmlns:rjm="http://schemas.oracle.com/sca/rejectedmessages"
name="rjm:IndustryFlowS0015FileReadAdapter">
<condition>
<action ref="writeToFile"/>
</condition>
</faultName>
<faultName xmlns:rjm="http://schemas.oracle.com/sca/rejectedmessages"
name="rjm:IndustryFlowS0004FileReadAdapter">
<condition>
<action ref="writeToFile"/>
</condition>
</faultName>
...
...
<Action id="writeToFile">
<fileAction>
<location>/home/fusdevu/EDF_Yoyager_RejectedMessages/OTHERS</location>
<fileName>RejectedMessage_%TIMESTAMP%.xml</fileName>
</fileAction>
</Action>
<Action id="ora-human-intervention">
<humanIntervention/>
</Action>
<Action id="writeToMDMErrorFile">
<fileAction>
<location>/home/fusdevu/EDF_Yoyager_RejectedMessages/MDM</location>
<fileName>RejectedMessage_%TIMESTAMP%.xml</fileName>
</fileAction>
</Action>
</Actions>
</faultPolicy>
</faultPolicies>


EXLANATION:
----------
The current behavior (of the fault framework not being invoked) is expected and as per design.

Basically , the fault management framework would catch all faults (business
and runtime) for an invoke activity
[Refer to section
12.4 Using the Fault Management Framework in the link below
http://download.oracle.com/docs/cd/E12839_01/integration.1111/e10224/bp_faults.htm#BABIGGIB]

Since , in the current test case the fault does not happen on an "invoke"
activity , the fault framework never gets executed.

Moreover , you should understand that the "validateXML" property is being set
on the partner-link and not on the FileAdapter Service itself - that means
that the FileAdapter "Read" will not validate the payload , but it would be
the "BPEL Receive Activity" which does the validation.

As mentioned before , since the fault framework will not be invoked on a
"BPEL Receive Activity Fault" the "invalidVariables" error would not be
handled by the fault framework.

The way to get past this issue would be  to validate the payload against the
schema at the FileAdapter Read Service itself  , so that the invalid file is
not passed on the BPEL Layer .

Please change the XSD  to include nxsd:validation="true" , remove
the "validateXML" property from the Partner-Link and redeploy the project
.
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns="http://www.example.org"
            targetNamespace="http://www.example.org"
            elementFormDefault="qualified"
             xmlns:nxsd="http://xmlns.oracle.com/pcbpel/nxsd"
              nxsd:validation="true">

This form of validation would control the publishing of invalid records and
provide information about XML validation errors.

Since the "fault" is now being thrown from the FileAdapter Service - the
fault framework would be invoked and the "writeFile" action would be
executed.

No comments:

Post a Comment