This documentation is for WSO2 Enterprise Service Bus version 4.8.1 . View documentation for the latest release.

All docs This doc

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This sample demonstrates the functionality of makefault mediator.  Here the Fault mediator (also called the Makefault mediator). Here a message is sent from the sample client to the back-end service through the ESB via 2 two faulty mediation options, and then appropriate SOAP error responses are sent back to the client using the send Send mediator.

Prerequisites

For a list of prerequisites, see Prerequisites to Start the ESB Samples.

...

  1. Run the following command from the <ESB_HOME>/samples/axis2Client directory to trigger a MSFT stock quote request to the back-end service.

    Code Block
    languagebash
    ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService -Dtrpurl=http://localhost:8280/ -Dsymbol=MSFT
  2. Run the following command from the <ESB_HOME>/samples/axis2Client directory to trigger a SUN stock quote request to the back-end service.

    Code Block
    languagebash
    ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService -Dtrpurl=http://localhost:8280/ -Dsymbol=SUN

Analyzing the output

When the MSFT stock quote is requested, an unknown host exception is generated according to the XML configuration in  synapse_sample_5.xml.

Code Block
languagehtml/xml
<case regex="MSFT">
  <send>
     <endpoint>
         <address uri="http://bogus:9000/services/NonExistentStockQuoteService"/>
     </endpoint>
  </send> 
</case>

This error message is captured and returned to the original client as a SOAP fault. You will see the following response on the console.

Code Block
languagehtml/xml
<soapenv:FaultEnvelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
	<faultcode>soapenv:Client</    <soapenv:Body>
        <soapenv:Fault>
            <faultcode xmlns:tns="http://www.w3.org/2003/05/soap-envelope">tns:Receiver</faultcode>
    <faultstring>Connection refused or failed for : bogus:9000 <  <faultstring>Error connecting to the back end</faultstring>
	<detail />
       </soapenv:Fault>
    </soapenv:Body>
</soapenv:Envelope>

When the SUN stock quote is requested, a connection refused exception is generated according according to the XML configuration in  synapse_sample_5.xml .

This error message is captured and returned to the original client as a SOAP fault. You will see the following response on the console.

Code Block
languagehtml/xml
<soapenv:FaultEnvelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
	<faultcode>soapenv:Client</faultcode>    <soapenv:Body>
    <faultstring> Connection refused or failed<soapenv:Fault>
for : localhost/127.0.0.1:9009</faultstring>
	<detail />
            <faultcode xmlns:tns="http://www.w3.org/2003/05/soap-envelope">tns:Receiver</faultcode>
            <faultstring>Error connecting to the back end</faultstring>
        </soapenv:Fault>
    </soapenv:Body>
</soapenv:Envelope>
Excerpt
hiddentrue

Example of message mediation in WSO2 ESB.