Versions Compared

Key

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

...

The portion of the message that needs to be validated is choosen chosen by evaluating the XPath expression. Then this message is validated against the schema specified. User Users can specify a sequence to be executed in case of a validation failure. This mediator provides an extension point by providing properties to configure the underline validation engine.

...

Table of Contents
maxLevel3
minLevel3
locationtop
styleborder:1
typeflat
separatorpipe

...

Syntax

Code Block
XML
XML
<validate [source="xpath"]>
   <property name="validation-feature-id" value="true|false"/>*
   <schema key="string"/>+
   <on-fail>
      mediator+
   </on-fail>

</validate>

The Validate Mediator validates the result of the evaluation of the source XPath expression, against the schema specified. If the source attribute is not specified, the validation is performed against the first child of the SOAP body of the current message. If the validation fails, the on-fail sequence of mediators is executed. Properties could be used to turn on/off some of the features of the validator on/off.

...

UI Configuration

  • Key - Schema location. It can  can be chosen either from the Configuration Registry or , Governance Registry (For Static Key) or from the Namespaces (For Dynamic Key). See Refer more information about the Registry Browser in Namespace.
    Info
    titleTip

    To add a new Schema Key, use the "Add New Schema Key" link.

  • Source - XPath expression to extract the XML that need needs to be validated. If not specified, the validation is performed against the first child of the SOAP body.
    Info
    titleTip

    You can click this 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.

  • Features 
Info
titleNote

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

...

Example

Code Block
XML
XML
<validate>
    <schema key="schema\sample.xsd"/>
         <on-fail>
                <makefault>
                    <code value="tns:Receiver"
                            xmlns:tns="http://www.w3.org/2003/05/soap-envelope"/>
                    <reason value="Invalid Request!!!"/>
                </makefault>
                <property name="RESPONSE" value="true"/>
                <header name="To" expression="get-property('ReplyTo')"/>
         </on-fail>
</validate>

In the above Validate Mediator configuration, the required schema for validating message messages going through the validate mediator has been is given as a registry key, schema\sample.xsd. In this sample configuration, there is no source attribute. Therefore, in this case, the Validate Mediator takes source as the first child of SOAP Body. Within on-fail, it is possible to specify mediation logic that should to be happened if the validation is failedfor the failed validation. In the above configuration, it creates a SOAP fault using makefault mediator and send sends that back that to the requested party.

Excerpt
hiddentrue

Description of the Validate Mediator in WSO2 ESB.