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:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:element name="myMessage"> <xsd:complexType> <xsd:sequence> <xsd:element name="myString" type="xsd:string"/> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:schema>
But what if your input message actually looked like this (note the lowercase â€˜sâ€™ in mystring):
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 ”cv
By turning on message validation prior to the Mapping node, you could catch such an issue early.
How can I enable message validation?
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.