How to validate incoming Messages for XML Structure and Data Type using existing XMLReceive Pipeline ?
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.
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.
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.
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=220.127.116.11, Culture=neutral, PublicKeyToken=b64a0508dbe93103
Now drop the modified file again.
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.
1 Comment »
About This Blog
This blog will have some of the Very Useful Concepts & Common Errors encountered in BizTalk Server Development and Maintenance.
The ideas & solutions posted in this blog may not always be a perfect solution.Obviously it is not possible for every one to master on every thing. There are some things which are learnt through experience and some things by research. I will post all possible references wherever applicable.
This is my personal blog and the ideas, thoughts, solutions mentioned here will be mine and no where related to my Employer.
- Walkthrough Using BizTalk Deployment Framework (BTDF)
- SSIS: Connecting to Oracle using Attunity Connector
- How to check if promoted property value exists before using it? (or) Using Exists Function in BizTalk (or) Missing Property Exception
- Contents ( 84 Posts )
- Difference between Message Context PropertyBase and Message Data PropertyBase.
- Part 1: ESB ToolKit Itineraries
- How to Enable BAM Continuation between Receive & Send Ports using Tracking Profile Editor
- Catching SOAP Faults from WCF Service in BizTalk Orchestration
- Splitting XML Files using Envelope Schema
- Can we use Non-Serializable Classes or Types in an Orchestration ?
- 378,187 hits
Unique Visitor Hits
add parameters Admin Console alternative design atomic scope Auto Linking Auto Mapping BAM Portal biztalk BizTalk 2010 BizTalk 2013 BizTalk Deployment Error BizTalk File Adapters BizTalk Mapper BizTalk Orchestrati BizTalk Server Config File biztalk server cross referencing bts_CleanupMsgbox Build Action Call Rules Shape Catching SOAP Faults change the Output file name Convert to Excel Convert to HTML Could not connect to TFS Could not load file or assembly EnvDTE cross reference functoids Custom Headers Debugging Orchestrations Deployment Documentation download visual studio download visual studio SP1 download windows server 2003 dtasp_CleanHMData Envelope Schema etw External assembly not updated get common id get common value id cross reference Install BizTalk Server 2009 Learn BizTalk Server Maps new BizTalk projects non-serializable Object reference not set to an instance of an object orchestration Post Deployment Scripts Post Processing Scripts Pre Deployment Scripts Pre Processing Scripts Project Creation Failed Project Reference Errors publishing orchestration publishing schema redistributable CAB file Reset BizTalk Reset Visual Studio REST restful service Schema not found Scripting Functoids Scripts serializable Splitting XML SQL Receive The directory name is invalid TOM TREE GENERATOR unittesting of schemas value cross reference Views Views not shown wcf WCF Service WCF Service Consuming Wizard
Site infoBizTalk Server Tutorial
Create a free website or blog at WordPress.com.