Versions Compared

Key

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

...

Table of Contents
maxLevel3
minLevel3
locationtop
styleborder:1locationtop
typeflat
separatorpipe

...

Syntax

...

Two versions can be chosen for the Fault Mediator:

...

SOAP 1.1
Anchor
Version SOAP 1.1
Version SOAP 1.1

For this version, the following options are available:

  • Fault Code
    • versionMismatch - SOAP version mismatch error.
    • mustUnderstand - SOAP error regarding "must understand" error.
    • Client - Client side error.
    • Server - Server side error.
  • Value/Expression
  • Fault String- The detailed fault string of the fault code. It can be given either as a string value or an expression.

    Info
    titleTip

    You can click on this the Namespaces link to add namespaces if you are providing an expression. You will be provided another panel named "Namespace Editor," where you can provide any number of namespace prefixes and URL that you have used in the XPath expression.

  • Fault Actor
  • Detail - Some information about the fault can be added to this field.

...

SOAP 1.2
Anchor
Version SOAP 1.2
Version SOAP 1.2

For this version, the following options are available:

...

Info
titleNote

You can configure the Mediator using XML. Click on "switch to source view" in the "Mediator" window.

...

Examples

Following are examples of different usages of the Fault Mediator.

Example one

In the following example, the testmessage string value is given as the reason for the SOAP error versionMismatch.

Code Block
XML
XML
<makefault xmlns="http://ws.apache.org/ns/synapse" version="soap11">
   <code xmlns:soap11Env="http://schemas.xmlsoap.org/soap/envelope/" value="soap11Env:VersionMismatch" />
   <reason value="test message " />
   <role></role>
</makefault>

Example two

The following sample proxy validates the content type using the Filter Mediator based on the Content-Type header property. If the result is true, it sends an exception back to the client using the Fault Mediator. Else, if the result is false, it continues the flow.

Code Block
languagexml
<proxy xmlns="http://ws.apache.org/ns/synapse" name="CheckContentType" transports="https http" startOnLoad="true" trace="disable">
<description/>
<target>
    <inSequence>
        <log level="custom">
            <property name="_______Content-Type" expression="get-property('transport','Content-Type')"/>
        </log>
        <filter source="get-property('transport','Content-Type')" regex="application/xhtml\+xml">
        <then>
            <log>
                <property name="Content-Type" expression="get-property('transport','Content-Type')"/>
                <property name="Decision" value="Exception, due to unexpected Content-Type."/>
            </log>
            <makefault version="soap11">
                <code xmlns:soap11Env="http://schemas.xmlsoap.org/soap/envelope/" value="soap11Env:Client"/>
                <reason value="Content-Type Error"/>
                <role/>
                <detail>Content-Type: application/xhtml+xml is not a valid content type.</detail>
            </makefault>
            <header name="To" scope="default" action="remove"/>
            <send/>
        </then>
        <else>
            <log>
                <property name="Content-Type" expression="get-property('transport','Content-Type')"/>
                <property name="Decision" value="Continue the mediation flow..."/>
            </log>
            <send>
                <endpoint>
                    <address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
                </endpoint>
            </send>
        </else>
    </filter>
</inSequence>
<outSequence>
    <send/>
</outSequence>
</target>
<publishWSDL uri="http://localhost:9000/services/SimpleStockQuoteService?wsdl"/>
</proxy>
Excerpt
hiddentrue

Description of the Fault Mediator in WSO2 ESB.