Petals-SE-Validation 1.1.x-1.3.x

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

Validation Component overview
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 (an home made Java Class) or an Enterprise Integration Pattern (EIP).
It could also be implemented by a BPEL process, but this latter needs that the WSDL proposed by the Validation component is correct and completed.
Note that BPEL can validate by itself the message during its processing, so it may be useless to use the Validation component in some cases.

Limitations

The validated / filtered content is always the payload from the input message.
Do not mistake XML-validation services for interceptors.

Neither to validate attached, nor to intercept and validate messages on the fly.
Interceptors would better fit this kind of use case.

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

Interceptor

Example of an interceptor configuration:

<?xml version="1.0" encoding="UTF-8"?>
<!--...-->
<petalsCDK:su-interceptors>
  <petalsCDK:send>
    <petalsCDK:interceptor name="myInterceptorName">
      <petalsCDK:param name="myParamName">myParamValue</petalsCDK:param>
      <petalsCDK:param name="myParamName2">myParamValue2</petalsCDK:param>
    </petalsCDK:interceptor>
  </petalsCDK:send>
  <petalsCDK:accept>
    <petalsCDK:interceptor name="myInterceptorName">
      <petalsCDK:param name="myParamName">myParamValue</petalsCDK:param>
    </petalsCDK:interceptor>
  </petalsCDK:accept>
  <petalsCDK:send-response>
    <petalsCDK:Interceptor name="myInterceptorName">
      <petalsCDK:param name="myParamName">myParamValue</petalsCDK:param>
    </petalsCDK:Interceptor>
  </petalsCDK:send-response>
  <petalsCDK:accept-response>
    <petalsCDK:Interceptor name="myInterceptorName">
      <petalsCDK:param name="myParamName">myParamValue</petalsCDK:param>
    </petalsCDK:Interceptor>
  </petalsCDK:accept-response>
</petalsCDK:su-interceptors>
<!--...-->

Interceptors configuration for SU (CDK)

Parameter Description Default Required
send Interceptor dedicated to send phase, for an exchange sent by a consumer - No
accept Interceptor dedicated to receive phase, for an exchange received by a provider - No
send-response Interceptor dedicated to send phase, for an exchange (a response) received by a consumer - No
accept-response Interceptor dedicated to receive phase, for an exchange sent (a response) by a provider - No
interceptor - name Logical name of the interceptor instance. It can be referenced to add extended parameters by a SU Interceptor configuration. - Yes
param[] - name The name of the parameter to use for the interceptor for this SU - No
param[] The value of the parameter to use for the interceptor for this SU - No

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.

Configuration of the component (CDK)

Parameter Description Default Required Scope
acceptor-pool-size The size of the thread pool used to accept Message Exchanges from the NMR. Once a message is accepted, its processing is delegated to the processor pool thread. 3
Yes
Runtime
processor-pool-size The size of the thread pool used to process Message Exchanges. Once a message is accepted, its processing is delegated to one of the thread of this pool. 10 Yes
Runtime
processor-max-pool-size The maximum size of the thread pool used to process Message Exchanges. The difference between this size and the processorpool-size represents the dynamic threads that can be created and destroyed during overhead processing time.
50
No Runtime
notifications Enable the notifications mode. The component produces and consumes generic notifications when receiving and sending messages. See the Petals View documentation for further details.
false
No
Installation
notif-retry-policy-min The notification retry policy is triggered if the notification component is not reachable at the starting of the component.
Delay before the first notification retry is attempted, in second.
1 bounds to notifications Installation
notif-retry-policy-max The notification retry policy is triggered if the notification component is not reachable at the starting of the component.
The maximum delay value authorized, in second.
60 bounds to notifications Installation
notif-retry-policy-factor The notification retry policy is triggered if the notification component is not reachable at the starting of the component.
The factor applies on the previous attempt, for each new attempt.
2
bounds to notifications Installation
notif-retry-policy-nb The notification retry policy is triggered if the notification component is not reachable at the starting of the component.
Number of retry once the maximum delay value is reached.
1000
bounds to notifications Installation
properties-file Name of the file containing properties used as reference by other parameters. Parameters of service-units and other parameters of the component reference the property name in the following pattern ${myPropertyName}. At runtime, the expression is replaced by the value of the property.

The value of this parameter is:
  • an URL
  • a file relative to the PEtALS installation path
  • an empty value to stipulate a non-using file
- No Installation

Definition of CDK parameter scope :

  • Installation: The parameter can be set during the installation of the component, by using the installation MBean (see JBI specifications for details about the installation sequence). If the parameter is optional and has not been defined during the development of the component, it is not available at installation time.
  • Runtime: The paramater can be set during the installation of the component and during runtime. The runtime configuration can be changed using the CDK custom MBean named RuntimeConfiguration. If the parameter is optional and has not been defined during the development of the component, it is not available at installation and runtime times.

Interceptor

Interceptors can be defined to inject some post or pre processing in the component during service processing.

Using interceptor is very sensitive and must be manipulate only by power users. An non properly coded interceptor engaged in a component can lead to uncontrolled behaviors, out of the standard process.

Example of an interceptor configuration:

<?xml version="1.0" encoding="UTF-8"?>
<!--...-->
<petalsCDK:component-interceptors>
  <petalsCDK:interceptor active="true" class="org.ow2.petals.myInterceptor" name="myInterceptorName">
    <petalsCDK:param name="myParamName">myParamValue</petalsCDK:param>
    <petalsCDK:param name="myParamName2">myParamValue2</petalsCDK:param>
  </petalsCDK:interceptor>
</petalsCDK:component-interceptors>
<!--...-->

Interceptors configuration for Component (CDK)

Parameter Description Default Required
interceptor - class Name of the interceptor class to implement. This class must extend the abstract class org.ow2.petals.component.common.interceptor.Interceptor. This class must be loadable from the component classloader, or in a dependent Shared Library classloader. - Yes
interceptor - name Logical name of the interceptor instance. It can be referenced to add extended parameters by a SU Interceptor configuration. - Yes
interceptor - active If true, the Interceptor instance is activated for every SU deployed on the component.
If false, the Interceptor can be activated:
-by the InterceptorManager Mbean at runtime, to activate the interceptor for every deployed SU.
-by a SU configuration
- Yes
param[] - name The name of the parameter to use for the interceptor. - No
param[] The value of the parameter to use for the interceptor. - No


This component does not have any specific configuration parameter.

Labels

components-se-family components-se-family Delete
se se Delete
validation validation Delete
components components Delete
1-1 1-1 Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.