...
Code Block | ||||
---|---|---|---|---|
| ||||
<validate [source="xpath"]> <property name="validation-feature-id" value="true|false"/>* <schema key="string"/>+ <on-fail> mediator+ </on-fail> </validate> |
...
UI Configuration
The mediator configuration can be divided into the following sections.
...
Parameter Name | Description | |||||
---|---|---|---|---|---|---|
Schema keys defined for Validate Mediator table | This parameter is used to specify the key for the schema location. It can be specified using one of the following methods.
Click Add Key to add a new schema key. Click Delete in the relevant row to delete a schema key.
| |||||
Source | The XPath expression to extract the XML that needs to be validated. The evaluation of this expression is validated against the schema specified in the Schema keys defined for Validate Mediator table. If this is not specified, the validation is performed against the first child of the SOAP body of the current message.
|
...
Parameter Name | Description |
---|---|
Location | The location of the schema to be imported. The value entered here should be equal to the value of the schema location attribute within the relevant <xsd:import> element in the parent schema. |
Key | The key to access the parent schema saved in the registry. Click either Configuration Registry or Governance Registry as relevant to select the key from the resource tree. |
Info | ||
---|---|---|
| ||
You can also configure the Mediator using XML. Click switch to source view in the Mediator window. |
...
Example
Example 1 - Basic configuration
In this example, the required schema for validating messages going through the validate mediator is given as a registry key, schema\sample.xsd
. No source attribute is specified, and therefore the schema will be used to validate the first child of the SOAP body. The mediation logic to follow if the validation fails is defined within the on-fail
element. In this example, the Fault Mediator is used to create a SOAP fault to be sent back to the party which sent the message.
...
In this example, the following schema named 08MockServiceSchema
is saved in the Registry. This schema is located in MockDataTypes.xsd
. A reference is made within this schema to another schema named 08SOAPFaults
which 08SOAPFaults
which is located in SOAPFaults.xsd
.
...
The schema used by the validate mediator is MockDataTypes.xsd
. In addition, a resource is used to import the 08
SOAPFaults
schema schema which is referred in the 08MockServiceSchema the 08MockServiceSchema
schema. Note that the value ../Common/SOAPFaults.xsd
which is specified as the location for the schema to be imported is the same as the location specified for 08
SOAPFaults
schema in the 08MockServiceSchema
configuration.
The on-fail
sequence of this Validate mediator includes a Log mediator which is added as a child to the Validate mediator. This log mediator uses two properties to generate the error message Validation failed ###
when the validation of a message against the schemas specified fails.
Excerpt | ||
---|---|---|
| ||
Description of the Validate Mediator in WSO2 ESB. |