View Source

{section}
{column}

h1. Features

The Validation Service-Engine allows to validate and filter Petals messages against an XML Schema.

\\
Each configuration of this component embeds an XML Schema (made up of one or several XSD files).
When such a configuration (i.e. service, i.e. service-unit) is called, it validates the received message against the XML Schema.
Depending on the called operation, the returned message is either a boolean (*validate* operation) or the received message or a fault (*filter* operation).
*filter* and *validate* are the only operations this component supports.

\\
This component only acts as service provider, not as a service consumer.
In fact, it provides a validation / filtering service (the filtering relies on the validity of the message against the XML Schema).


h1. Recommended usage

The Validation component may be used before calling a critical service.
It allows to make sure the message to send has the right shape.
For some services, this can be useless. For some others though, it can be critical to perform this check.

\\
One typical example would be a service converting the received message as data and manipulating it then (e.g. to insert it into a database).
In Petals ESB, that would concern the Petals-BC-SQL component or even the Petals-SE-Talend component.
Notice that this last one has a built-in feature to validate received messages against the job's WSDL.

Another example could be a service that accesses an EJB.
The received message is mapped to a Java object that is about to be manipulated in a JEE container.
Making sure the sent message is valid may prevent errors from occurring later in the processing.

\\
In a perfect SOA world, this component would be useless.
Every service would have a WSDL, and every service consumer would rely on this WSDL to send a message.
But this is only good practices. It happens that service consumers do not send the perfect messages.

It can be the case with *integration* use cases (e.g. with an EIP - Enterprise Integration Pattern - or a POJO that consumes a service by generating dynamically the message to send).
Before calling this service, you might want to ensure the validity of the built message. An this is where you will use the Validation component.

Roughly, the principle looks like

{code:lang=java}
if( validationService.validate( MSG )) {
criticalService.criticalOperation( MSG );
}
else {
log( "The message was invalid." );
}
{code}


h1. General information

h2. Validation and chaining services

Following our previous algorithm, it appears that validating or filtering a message only makes sense if this message is going to be sent to another service.
That supposes that there is a chaining service, that will first call the validation service, and then call the real target service.

# Message from the chaining service to the validation / filtering service.
# Response from the validation / filtering service to the chaining service (the MEP is InOut, always, no matter what the operation is).
# Message from the chaining service to the real target service.
# Optional response, depending on the MEP for the second service.

\\
This chaining service can be implemented by a POJO (a Java service that runs in Petals) or an Enterprise Integration Pattern (EIP).
It could also be implemented by a BPEL process, but in fact, that would not be a good idea.
A BPEL process needs any called service to have a WSDL, and sends messages according to these WSDLs.
Typically, working with assumes that you are in a perfect SOA world. Thus, using the Validation component with BPEL is useless.


h2. Validate or filter

The Validation component supports two operations.

h3. The "validate" operation

*valide* validates the received message against the XML Schema embedded in the service-unit.
The returned message is either

{code:lang=xml}
<!-- The target name space depends on the version of the Validation component -->
<tns:validateResponse xmlns:tns='http://petals.ow2.org/components/validation/version-1'>
<tns:valid>true</tns:valid>
</tns:validateResponse>
{code}

(if the message is valid), or

{code:lang=xml}
<!-- The target name space depends on the version of the Validation component -->
<tns:validateResponse xmlns:tns='http://petals.ow2.org/components/validation/version-1'>
<tns:valid>false</tns:valid>
</tns:validateResponse>
{code}

(if the message is invalid).

\\
The associated name space (a WSDL operation is a QName) depends on the version of the Validation component.
For the version 1.1, this name space is http://petals.ow2.org/components/validation/version-1
This operation only supports the *InOut* message exchange pattern.


h3. The "filter" operation

*filter* filters the received message by validating it against the XML Schema embedded in the service-unit.
If the message is valid, then it is returned as the response.
Otherwise, a fault is raised.

\\
The associated name space (a WSDL operation is a QName) depends on the version of the Validation component.
For the version 1.1, this name space is http://petals.ow2.org/components/validation/version-1
This operation only supports the *InOut* message exchange pattern.

{warning}
If the operation is invalid (i.e. is neither *validate*, nor *filter*), then *filter* is the operation by default.
{warning}


h2. Validation services and WSDL interfaces

By default, services deployed on the Validation component do not need a WSDL.
However, as a good practice, it is better to provide it one.

The operations are known.
The only unknown is whether the input mesages will be *anyType* or the *exact top element of the XML Schema*.
It is let to the choice of the user.

The output message for the operation *filter* should however be described by the XML Schema.


h2. Limitations

Configurations for this component cannot be used as a proxy to call other services.
Neither to validate attached, nor to intercept and validate messages on the fly.
Interceptors would better fit this kind of use case.

\\
The validated / filtered content is always the payload from the input message.


h1. Component configuration

The component can be configured through its JBI descriptor file, as shown below.
{code:lang=xml}<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<jbi version="1.0"
xmlns='http://java.sun.com/xml/ns/jbi'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:petalsCDK="http://petals.ow2.org/components/extensions/version-5">

<component type="service-engine">
<identification>
<name>petals-se-validation</name>
<description>A VALIDATION Service Engine</description>
</identification>

<component-class-name description="Validation Component class">org.ow2.petals.se.validation.ValidationComponent</component-class-name>
<component-class-path><path-element/></component-class-path>
<bootstrap-class-name>org.ow2.petals.component.framework.DefaultBootstrap</bootstrap-class-name>
<bootstrap-class-path><path-element/></bootstrap-class-path>

<petalsCDK:acceptor-pool-size>3</petalsCDK:acceptor-pool-size>
<petalsCDK:processor-pool-size>10</petalsCDK:processor-pool-size>
<petalsCDK:ignored-status>DONE_AND_ERROR_IGNORED</petalsCDK:ignored-status>
<petalsCDK:notifications>false</petalsCDK:notifications>
<petalsCDK:jbi-listener-class-name>org.ow2.petals.se.validation.listener.JBIListener</petalsCDK:jbi-listener-class-name>
</component>
</jbi>{code}


\\
The component configuration includes the configuration of the CDK. The following parameters correspond to the CDK configuration.
{include:0 CDK Component Configuration Table}

\\
This component does not have any specific configuration parameter.

\\
{warning}
The Petals-SE-Validation component can only handle messages coming from inside the bus. Therefore, you cannot specify an external-listener class-name.
{warning}


h1. Service Configuration

h2. Service Unit descriptor

The Service Unit descriptor file ( jbi.xml ) looks like this:
{code:lang=xml}<?xml version="1.0" encoding="UTF-8"?>
<jbi:jbi version="1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jbi="http://java.sun.com/xml/ns/jbi"
xmlns:petalsCDK="http://petals.ow2.org/components/extensions/version-5"
xmlns:validation="http://petals.ow2.org/components/validation/version-1"
xmlns:serviceNs="http://petals.ow2.org/simpletransformation">

<jbi:services binding-component="false">
<jbi:provides
interface-name="serviceNs:ValidationInterface"
service-name="serviceNs:ValidationService"
endpoint-name="ValidationEndpoint">

<!-- WSDL file -->
<petalsCDK:wsdl>your optional description wsdl file.wsdl</petalsCDK:wsdl>

<!-- Validation specific fields -->
<validation:schema>schema.xsd</validation:schema>
</jbi:provides>
</jbi:services>
</jbi:jbi>
{code}

\\
A JBI descriptor for an Validation service-unit can only define one _provides_ block.

\\
*Configuration of a Service Unit to expose an validation / filtering service into Petals ESB:*

|| Parameter || Description || Default || Required ||
| schema | Location of the XSD schema. This path must be a relative path from the root of the SU package. \\ | \- | Yes |

\\
{include:0 CDK SU Provide Configuration}
\\
{include:0 CDK Interceptor configuration for SU}


h2. Service Unit content

The service unit must contain the XML Schema and the JBI descriptor (jbi.xml file).
It is also highly recommended to provide a WSDL description for this service (though it is optional).
This WSDL is not mandatory, but not providing it will prevent your service from interacting with other Petals services and components.

\\
The directory structure of a SU for the Petals-SE-Validation looks like this:

{noformat}
su-xslt-TransformationName-provide.zip
+ META-INF
- jbi.xml
+ XsltService.wsdl (recommended)
+ myfile.xsd (required)
+ myfile2.xsd (required if myfile2.xsd is imported in myfile.xsd)
{noformat}
{column}

{column:width=350px}
{panel:title=Table of contents}{toc}{panel}
{panel:title=Contributors}{contributors:order=name|mode=list}{panel}
{column}
{section}