It is recommended that you enable message validation in your WebSphere Message Broker v8 or IBM Integration Bus v9 message flows when you use Mapping nodes.
What is message validation?
Validation is the process of checking a message’s structure, and optionally the values within, based on a description called a schema.
This might include ensuring that:
complex elements have the correct composition and content validation
all data fields contain the correct type of data
data fields conform to the value constraints in the message model
all mandatory fields are present in the message
only the expected fields are present in the message
message elements are in the correct order
How can it help when using Mapping nodes?
The Mapping node relies on schema definitions, but it does not enforce them.
If the input message does not conform to the schema being used, the output you expect to see might not be produced.
For example, you use the following xml schema:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:element name="myString" type="xsd:string"/>
You create a map which copies the path myMessage/myString from input to output:
But what if your input message actually looked like this (note the lowercase ‘s’ in mystring):
<myMessage><mystring>Hello</my s tring></myMessage>
The Map would fail to find an input value for the path myMessage/myString and so would not execute the Move transform. In turn, because no children of myMessage were created on the output side, there would be no implicit creation of the parent myMessage element either. In this case your output would actually be empty!
If message validation had been enabled you would have seen an error instead:
BIP5025 - XML schema validation error ''cvc-complex-type.2.4.a: Expecting element with local name "myString" but saw "mystring".'' on line '1' column '22' when parsing element ''/Root/XMLNSC/myMessage''.
By turning on message validation prior to the Mapping node, you could catch such an issue early.
How can I enable message validation?
Message validation can be enabled directly on a number of input nodes such as the MQInput, and SOAPInput nodes.
Alternatively, you can validate immediately prior to a Mapping node by utilizing a Validate node which has a similar set of capabilities.
You can choose whether to validate just the structure (Content), or the structure and the values within them (Content and value). Ideally you should validate both content and value.
If a message fails to pass validation, then the specified Failure action will be taken. You can choose to generate an exception or write messages to the system log or user trace.
Note: There are validation options on the Mapping node itself, but these apply to the output message only.
Should I always enable validation?
During the development of your integration solutions, it is recommended that you enable validation.
However, for other environments such as test or production, you should only leave validation on if your solution requires it because of the extra processing involved.
Where can I get more information about message validation?
The IBM Integration Bus Knowledge Center contains more information about message validation, which nodes provide validation options and the actions you can take should a message fail validation.
IBM Integration Bus Knowledge Center - Validating messages