Petals-SE-Validation 1.1

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).

Contributors
No contributors found for: authors on selected page(s)

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.

A typical example

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

if( validationService.validate( MSG )) {
     criticalService.criticalOperation( MSG );
}
else {
      log( "The message was invalid." );
}

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.

  1. Message from the chaining service to the validation / filtering service.
  2. Response from the validation / filtering service to the chaining service (the MEP is InOut, always, no matter what the operation is).
  3. Message from the chaining service to the real target service.
  4. 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 BPEL means you assume that you are in a perfect SOA world. Thus, using the Validation component with BPEL is useless.

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.

Creating a XML Validation service (Provides mode)

Each Validation service runs on the Petals Validation component.
The Petals Validation component has native operations to invoke. These operations are inherited by the Validation services.
A Validation service cannot add additional operations. It only has the ones of the XSLT component.

The version 1.1 of the Petals Validation component exposes two operations.

  • validate: the received message is validated against a XML-Schema. The service returns a boolean response indicating if the message is valid.
  • filter: the received message is validated against a XML-Schema. If the message is valid, this same message is returned. Otherwise, a fault is raised.

The "validate" operation

The fully qualified name of this operation is:

  • Name space URI: *http://petals.ow2.org/components/validation/version-1*
  • Local part: validate


This operation only supports the InOut message exchange pattern (MEP).
When invoking this operation, you must call it using its fully qualified name.


Here is the execution flow for this operation:

  1. The received message is validated against the XML-Schema embedded by the service.
  2. The validation response is wrapped into a message and sent back.


More precisely, if the message is valid, the returned message is

<!-- 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>


Otherwise, it is

<!-- 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:comment>The reason explaining why it is invalid.</tns:comment>
</tns:validateResponse>

The "filter" operation

The fully qualified name of this operation is:

  • Name space URI: *http://petals.ow2.org/components/validation/version-1*
  • Local part: filter


This operation only supports the InOut message exchange pattern (MEP).
When invoking this operation, you must call it using its fully qualified name.


Here is the execution flow for this operation:

  1. The received message is validated against the XML-Schema embedded by the service.
  2. If the message is valid, this same message is sent back. Otherwise, a fault is raised.


<!-- The target name space depends on the version of the Validation component -->
<tns:validationFault xmlns:tns='http://petals.ow2.org/components/validation/version-1'>
     <tns:message>The fault message.</tns:message>
<tns:validationFault>


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

WSDL definitions

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 messages 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.

JBI descriptor

The Service Unit descriptor file ( jbi.xml ) looks like this:

<?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>


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


Configuration of a Service Unit to provide a service (JBI)

Parameter Description
Default
Required
provides Describe the JBI service that will be exposed into the JBI bus. Interface (QName), Service (QName) and Endpoint (String) attributes are required. - Yes

Configuration of a Service Unit to provide a service (CDK)

Parameter Description
Default
Required
timeout Timeout in milliseconds of a synchronous send. This parameter is used by the method sendSync (Exchange exchange) proposes by the CDK Listeners classes.
Set it to 0 for an infinite timeout.
30000 No
exchange-properties This sections defines the list of properties to set to the JBI exchange when processing a service. - No
message-properties This sections defines the list of properties to set to the JBI message when processing a service. - No
validate-wsdl Activate the validation of the WSDL when deploying a service unit. true No
wsdl
Path to the WSDL document describing services and operations exposed by the provided JBI endpoints defined in the SU.
The value of this parameter is :
  • an URL
  • a file relative to the root of the SU package
    If not specified, a basic WSDL description is automaticaly provided by the CDK.
- No
forward-attachments
Defines if attachment will be forwarded from IN message to OUT message.
false No
forward-message-properties
Defines if the message properties will be forwarded from IN message to OUT message. false No
forward-security-subject
Defines if the security subject will be forwarded from IN message to OUT message. false No

Configuration of a Service Unit to provide a service (Validation)

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

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:

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)

Configuring the component

The component can be configured through its JBI descriptor file, as shown below.

<?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>


The component configuration includes the configuration of the CDK. The following parameters correspond to the CDK configuration.

Unable to render {include} Couldn't find a page to include called: 0 CDK Component Configuration Table


This component does not have any specific configuration parameter.

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.