How to shift between fault sequence and custom fault sequence
Temporary
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://ws.apache.org/ns/synapse">
<proxy name="Faultproxy"
transports="https http"
startOnLoad="true"
trace="disable">
<description/>
<target>
<inSequence>
<makefault version="soap11">
<code xmlns:soap11Env="http://schemas.xmlsoap.org/soap/envelope/"
value="soap11Env:VersionMismatch"/>
<reason value="500"/>
<role/>
</makefault>
<respond/>
</inSequence>
</target>
</proxy>
<proxy name="Axis2ProxyService"
transports="https http"
startOnLoad="true"
trace="disable">
<description/>
<target>
<inSequence onError="fault">
<property name="FORCE_ERROR_ON_SOAP_FAULT"
value="true"
scope="default"
type="STRING"/>
<send>
<endpoint key="Axis2EP"/>
</send>
</inSequence>
<outSequence>
<log level="full"/>
<send/>
</outSequence>
<faultSequence>
<log level="custom">
<property name="faultSequence" value="** Its Inline faultSequence ****"/>
</log>
<payloadFactory media-type="xml">
<format>
<sequence xmlns="">$1</sequence>
</format>
<args>
<arg value="Its Inline faultSequence "/>
</args>
</payloadFactory>
<send/>
</faultSequence>
</target>
</proxy>
<endpoint name="Axis2EP">
<address uri="http://localhost:8280/services/Faultproxy"/>
</endpoint>
<sequence name="fault">
<log level="full">
<property name="MESSAGE" value="Executing default "fault" sequence"/>
<property name="ERROR_CODE" expression="get-property('ERROR_CODE')"/>
<property name="ERROR_MESSAGE" expression="get-property('ERROR_MESSAGE')"/>
</log>
<log level="custom">
<property name="fault" value="================Its fault Sequence================"/>
</log>
<payloadFactory media-type="xml">
<format>
<sequence xmlns="">$1</sequence>
</format>
<args>
<arg value="Its fault Sequence "/>
</args>
</payloadFactory>
<send/>
<drop/>
</sequence>
<sequence name="main">
<log/>
<drop/>
</sequence>
</definitions>
=============================================
Tips To Remember
1. Generating a response inside the proxy service for get request you need to add this property after removing the To header.
<property name="NO_ENTITY_BODY" scope="axis2" action="remove"/>
2. Making of soap-fault generating proxy
<proxy name="Faultproxy"
transports="https http"
startOnLoad="true"
trace="disable">
<description/>
<target>
<inSequence>
<makefault version="soap11">
<code xmlns:soap11Env="http://schemas.xmlsoap.org/soap/envelope/"
value="soap11Env:VersionMismatch"/>
<reason value="500"/>
<role/>
</makefault>
<respond/>
</inSequence>
</target>
</proxy>
3. Script mediator to log thread names for wso2 esb each request
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://ws.apache.org/ns/synapse">
<localEntry key="stockquoteScript"
src="file:repository/samples/resources/script/stockquoteTransform.js"/>
<sequence name="fault">
<log level="full">
<property name="MESSAGE" value="Executing default "fault" sequence"/>
<property name="ERROR_CODE" expression="get-property('ERROR_CODE')"/>
<property name="ERROR_MESSAGE" expression="get-property('ERROR_MESSAGE')"/>
</log>
<drop/>
</sequence>
<sequence name="main">
<in>
<script language="js" key="stockquoteScript" function="transformRequest"/>
<send>
<endpoint>
<address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
</endpoint>
</send>
</in>
<out>
<script language="js" key="stockquoteScript" function="transformResponse"/>
<log level="custom">
<property name="Fooo" expression="get-property('threadName')"/>
</log>
<send/>
</out>
</sequence>
</definitions>
Add a script as a local entry (eg: URL repository/samples/resources/script/stockquoteTransform.js)
* Your stockquoteTransform.js should look like this.
function transformRequest(mc) {
var symbol = mc.getPayloadXML()..*::Code.toString();
mc.setPayloadXML(
<m:getQuote xmlns:m="http://services.samples">
<m:request>
<m:symbol>{symbol}</m:symbol>
</m:request>
</m:getQuote>);
}
function transformResponse(mc) {
mc.setProperty("threadName", java.lang.Thread.currentThread().getName());
java.lang.Thread.sleep(10000);
}
Now open a soapUI and send your soap request to http://localhost:8280/ main sequence.
Now
you should be able to see entries displayed in the console of each
thread name. Alternatively you can also open the wso2carbon.log file
which resides at [CARBON_HOME]/repository/logs to view the thread names
generated to handle each request.