Validating data types in a BizTalk receive location

In BizTalk

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.

Sample schema

The sample XML schema defintion (XSD) contains the following structure:

image

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.

 

The pipeline

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.

image

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.

image

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

imageThe DocumentSpecName for my XSD looks like this: “DBLOG.ValidateMessage.IntegerSchema, DBLOG.ValidateMessage, Version=1.0.0.0, Culture=neutral, PublicKeyToken=349a4171d9432c58”.

 

Running it

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:

image

That’s it! Happy BizTalking!

daniel
daniel
Developer
Recent Posts
Contact Us

We're not around right now. But you can send us an email and we'll get back to you, asap.

Not readable? Change text. captcha txt

Start typing and press Enter to search