Validating data types in a BizTalk receive location
This blog post is about validating data types in a BizTalk receive location. By default no data type validation is performed unless explicitly set. This approach could save a’lot of grief since the message is refused before it has the possibility of wreaking havoc in the BizTalk message box.
The sample XML schema defintion (XSD) contains the following structure:
The data type of the IntegerValue-element is set to “xs:int”.
Configuring the receive location
By default the data types in the XSD are not enforced when the XML is disassembled in by the pipeline. The XMLReceive pipeline does not know which XSD it should validate against. The main task of the XMLReceive pipeline is simply to disassemble the XML before it’s published to the message box. In order to validate the XML received by the receive location we need to instruct the pipeline to do so, and which XSD it should validate against.
This is done by configuring the XMLReceive pipeline (if you’ll be receiving XML!). Click the “configure” button to bring up the properties dialogue box.
The two properties we need to set are ValidateDocument and DocumentSpecNames. ValidateDocument is pretty straightforward: we’re simply telling the pipeline to validate the message. But by not defining which XSD we want to validate against we’ll receive an error saying “Validation can only be performed when document schemas are provided”.
The DocumentSpecName property
Looking at the pipeline properties we’ll see that the DocumentSpecNames has not been configured. It’s reasonable to assume that this is the schema namespace. Wrong.This is actually the full path to both the assembly and namespace of the schema.
BizTalk does not know at the pipeline level in which assembly it should be looking. So we need to explicitly define this. The easiest way to get this information is by clicking “Schemas” of the application in the adminstration console. Then bring up the information for the schema you wish to validate against and copy “Name” and “Assembly”.
If the pipeline is properly configured the error when the data type in the XML isn’t valid should display like this in the event log:
That’s it! Happy BizTalking!