BizTalk 2010 Recipes : Creating a Schema Based on an Existing XML Document
1. Problem
You have an existing XML document that you want to create a BizTalk schema for.
2. Solution
In many situations, you will need to consume XML documents in BizTalk that already exist. Rather than creating the schema by hand, you can have BizTalk automatically generate the schema for you. The steps for doing this are as follows:
In a BizTalk project, right-click the project in Solution Explorer, and select Add => Add Generated Items.
In the dialogue box that opens, select Generate Schemas.
The Generate Schemas window appears. Set the Document type value to "Well-Formed XML (Not Loaded)" and set the "Input file" value to the pre-=existing instance of the XML that you are basing the schema on. See Figure 1.
Figure 1. Specifying a well-formed XML instance
NOTE
You may get an error similar to that shown in Figure 2. If so, simply run the InstallWFX.vbs script in the file path specified in the error message and run the schema generator tool again.
Figure 2. The error message that occurs the first time the schema generator is run
Click OK. The schema will be automatically created and added to your BizTalk project.
3. How It Works
There are several other options for generated items, but this is the most helpful of the group. You would be amazed at the number of developers who try to hand code their own schemas based on XML documents that already exist.