How to validate incoming Messages for XML Structure and Data Type using existing XMLReceive Pipeline ?

Posted: March 2, 2011  |  Categories: Pipelines Uncategorized

In every project we develop, we may have to validate input message against schemas for XML Structure and Data Type of XML Elements.

Instead of developing a custom pipeline component for this task, the existing XMLReceive Pipeline can be used.

This can be done in 2 simple steps. This article will explain this validation in full Detail.

Setup the Project:

1. Create a new Project and add a schema with a single Element as shown below. Set the datatype to UnsignedInt.

2. Create a dummy orchestration (not actually required, just for more clarity :)). Receive the message of the above schema type and display its contents into Event Log using an Expression shape.

3. Deploy the application.

Test for the Validation:

Configure the Receive port of the orchestration with a Physical Receive Port.

Ideal XML for the schema deployed should be as follows.

<ns0:Root xmlns:ns0=”http://BizTalk_Server_Project1.Schema1“>


Test Scenario 1:

Do not set any validation. Use XML Receive Pipeline with default options. Drop the file in the Folder.

Result 1: No Error. Message Contents will be shown in Event Log.

Test Scenario 2:

Modify the structure of the File as below and drop it again.

<ns0:Root xmlns:ns0=”http://BizTalk_Server_Project1.Schema1“>


Result 2: Still you won’t get any error. Event log will have a normal entry as shown below.

But this should not be ideal. You should be expecting an error which has not happened.

Test Scenario 3:

Set Validate Document in Receive Pipeline to True and drop the file with modified structure again.

Result 3:

An error is thrown saying “Validation can only be performed when document schemas are provided.”

This error is thrown because, for the XML Receive Pipeline, we set the Validate Document to True. But we didn’t provide the name of the schema, against which the XML should be verified. Hence, we see this error.

Test Scenario 4:

Provide the schema name for DocumentSpecNames property of the Receive Pipeline.
It should be given in the following format.

BizTalk_Server_Project1.Schema1, BizTalk Server Project1, Version=, Culture=neutral, PublicKeyToken=b64a0508dbe93103

Now drop the modified file again.

Result 4:

An error will be shown that an extra element is there.

This is it. Now you have set up validation of XML Message using XML Receive Pipeline. The entire validation message should now be displayed.

You can also set up routing of failed message to capture all the messages that failed validation.

– Shiv

#1 all-in-one platform for Microsoft BizTalk Server management and monitoring

Back to Top