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