1. Problem
You have an inbound or outbound document that requires validation beyond checking for well-formed XML.
2. Solution
You can use a send or receive
pipeline to perform a strict validation of an instance of an XML
document by providing validation against an XSD schema. BizTalk Server
provides an XML Validator pipeline component for validating XML (schema)
documents. If the inbound or outbound document is not XML, it must be
converted to XML prior to validation. The following steps define how to
create a receive pipeline that can be used to validate an XML document.
The steps are similar to those for configuring a send pipeline.
Open the project that will contain the pipeline.
Right-click the project, and select Add => New Item.
In the Add New Item dialog box, select Receive Pipeline, and provide a name. Then click Add.
Drag
the XML Validator component from the BizTalk Pipeline Components
section of the toolbox to the Drop Here location under the Validate
label, as shown in Figure 1.
Select the ellipsis next to the Document Schemas
property for the XML Validator component (in the Properties window) to
launch the Schema Collection Property Editor dialog box, shown in Figure 2.
Use the Schema Collection Property Editor to add schemas to the collection, and then click OK.
Build and deploy the project.
Now that you have created the validation pipeline, when configuring the Receive Pipeline property of a receive location, select the pipeline from the list of available receive pipelines.
3. How It Works
Strict validation of an XML
document is achieved with the use of a validation pipeline. The
XMLReceive receive pipeline and XMLTransmit send pipeline that come with
BizTalk Server will validate only that an XML document is well formed.
It will not perform strict validation of the document, including data
types and restriction values (length, enumerations, patterns, and so
on).
You use the XML Validator
pipeline component to validate the instance document. This component
may be placed in any pipeline stage, except the Disassemble or Assemble
stages. If you do not add a schema using the Schema Collection Property
Editor dialog box for the component, the component will attempt to
locate an appropriate schema to validate against based on the namespace
and root node of the document. If no schema is found to validate
against, or the document fails validation, an error will occur, and the
instance will be terminated.