Generally faultSequence get executed for errors, exception in mediation flow, such as trying to process malformed xml, endpoint timeout, any mediation errors, etc. It is not designed to execute when error response get received. But you can set property to execute faultSequence when a standards soap fault (SOAPFault) response received from an endpoint. It becomes handy in service chaining because we do not need to check and verify for fault response before calling the next endpoint.
You can force to execute faultSequence by setting "FORCE_ERROR_ON_SOAP_FAULT" property to "true"
<property name="FORCE_ERROR_ON_SOAP_FAULT" value="true" scope="default" type="STRING"/>
Sample synapse configuration to depict usage of FORCE_ERROR_ON_SOAP_FAULT
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--SAMPLE PROXY--> | |
<proxy name="echoProxy" transports="https http" startOnLoad="true" trace="disable"> | |
<description/> | |
<target faultSequence="echoFaultSeq"> | |
<endpoint> | |
<address uri="http://localhost:8280/services/echo.echoHttpSoap11Endpoint"/> | |
</endpoint> | |
<inSequence> | |
<log level="custom"> | |
<property name="MESSAGE" value="echo proxy"/> | |
</log> | |
<property name="FORCE_ERROR_ON_SOAP_FAULT" value="true" scope="default" type="STRING"/> | |
</inSequence> | |
</target> | |
</proxy> | |
<!--SAMPLE FAULT SEQUENCE echoFaultSeq for echoProxy--> | |
<sequence name="echoFaultSeq"> | |
<log level="custom"> | |
<property name="SEQUENCE" value="echoFaultSeq"/> | |
<property name="MESSAGE" value="SOAPFault Received ... !"/> | |
</log> | |
<send/> | |
</sequence> |
In above sample simply front echo service which comes by default with WSO2 ESB. If you call "echoProxy" which echo service returns SOAPFault such as sending alphabetical character for echoInt operation, you can see the fault sequence "echoFaultSeq" get executed.
No comments:
Post a Comment