Versions Compared

Key

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

The Fault Mediator (also called the Makefault Mediator) transforms the current message into a fault message. However, but this mediator does NOT not send itthe converted message. The Send Mediator needs to be invoked to send a fault message created this wayvia the Fault mediator. The fault message's To header is set to the Fault-To of the original message (if such a header exists in the original message). You can create the fault message as a SOAP 1.1, SOAP 1.2, or plain-old XML (POX) fault.

...

Table of Contents
location
maxLevel3
minLevel3
locationtop
styleborder:1
toptypeflat
separatorpipe

...

Syntax

Code Block
XML
XML
<makefault [version="soap11|soap12|pox"]>
   <code (value="literal" | expression="xpath")/>
   <reason (value="literal" | expression="xpath")>
   <node>?
   <role>?
   <detail>?
</makefault>

...

UI Configuration

Choose one of the following versions for the Fault Mediator:

Click on the relevant tab to view the required UI configuration pending on whether you want to create the fault message as a SOAP 1.1

...

fault, SOAP 1.2

...

fault or a plain-old XML (POX) fault.

...

Localtabgroup
Localtab
titleSOAP 1.1

...

Image Added

The parameters available to configure the Fault mediator to create a SOAP 1.1

...

Image Removed

For this version, the following options are available:

...

  • versionMismatch - SOAP version mismatch error.
  • mustUnderstand - SOAP error regarding "must understand" error.
  • Client - Client side error.
  • Server - Server side error.

...

fault are as follows.

 

Parameter NameDescription
Fault Code

 This parameter is used to select the fault code for which the fault string should be defined. Possible values are as follows.

  • versionMismatch: Select this to specify the fault string for a SOAP version mismatch.
  • mustUnderstand: Select this to specify the fault string for the mustUnderstand error in SOAP.
  • Client: Select this to specify the fault string for client side errors.
  • Server: Select this to specify the fault string for server side errors.
Fault String

The detailed fault string of the fault code.

...

The following options are available.

  • value: If this option is selected, the fault string is specified as a string value

...

  • .
  • expression: If this option is selected, the fault string is specified as an expression.
Info
titleTip

You can click

...

NameSpaces to add namespaces if you are providing an expression.

...

Then the Namespace Editor panel would appear where you can provide any number of namespace prefixes and

...

URLs used in the XPath expression. 

Fault Actor

...

The element of the SOAP fault message which is used to capture the party which caused the fault.
DetailThis parameter is used to enter a custom description of the error.
Localtab
titleSOAP 1.2

...

Image Added

The parameters available to configure the Fault mediator to create a SOAP 1.2

...

Image Removed

For this version, the following options are available:

...

fault are as follows.

Parameter NameDescription
Code

 This parameter is used to select the fault code for which the reason should be defined. Possible values are as follows.

  • versionMismatch: Select this to specify the reason for a SOAP version mismatch.
  • mustUnderstand: Select this to specify the reason for the mustUnderstand error in SOAP.
  • dataEncodingUnknown: Select this to specify the reason for a SOAP encoding error.
  • Sender

...

  • : Select this ti specify the reason for a sender-side error.
  • Receiver

...

Reason- Reason describing the fault code.

...

  • : Select this to specify the reason for a receiver-side error.

...

ReasonThis parameter is used to specify the reason for the error code selected in the Code parameter. The following options are available.
  • value: If this option is selected, the reason is specified as a string value.
  • expression: If this option is selected, the reason is specified as an expression.
Info
titleTip

You can click NameSpaces to add namespaces if you are providing an expression.

...

Then the Namespace Editor panel would appear where you can provide any number of namespace prefixes and

...

URLs used in the XPath expression. 

Role

...

The SOAP 1.

...

1 role

...

name.
Node

...

The SOAP 1.2 node name.
Detail

...

This parameter is used to enter a custom description of the error.
Localtab
titlePlain-old XML (POX)

...

Image Removed

...

Image Added

The parameters available to configure the Fault mediator to create a plain-old XML (POX) fault are as follows.

Parameter NameDescription
Reason

This parameter is used to enter a custom fault message. The following options are available

...

.

  • value: If this option is selected, the fault message is specified as a string value

...

  • .
  • expression: If this option is selected, the fault message is specified as an expression.
Info
titleTip

You can click

...

NameSpaces to add namespaces if you are providing an expression.

...

Then the Namespace Editor panel would appear where you can provide any number of namespace prefixes and

...

URLs used in the XPath expression. 

Detail

...

Info

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

Image Removed

...

This parameter is used to enter details for the fault message. The following options are available.

  • value: If this option is selected, the detail is specified as a string value.
  • expression: If this option is selected, the detail is specified as an expression.
Info
titleTip

You can click NameSpaces to add namespaces if you are providing an expression. Then the Namespace Editor panel would appear where you can provide any number of namespace prefixes and URLs used in the XPath expression. 

Info
titleNote

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

Image Added

 

...

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>

...

Samples

Sample 5: Creating SOAP Fault Messages and Changing the Direction of a Message.