This post disappeared from a previous blog of mine so I'm reposting it.
I've been doing some research on custom adapter development and one of the issues that came up was figuring out how to do the schema generation. BizTalk Server 2004 includes a wizard that will generate schemas from Xml instance documents. I decided to figure out how it worked – and if it could be reused.
It is possible to reuse this functionality. Here's how you do it:
- Create a console project.
- Reference the Microsoft.BizTalk.WFXToXSDGenerator.dll and XSDInfer.dll assemblies in the [installDir]\Microsoft BizTalk Server 2004\SDK\Utilities\Schema Generator directory.
- Reference the Microsoft.BizTalk.SchemaEditor.Extensibility.dll assembly in the [installDir]\Program Files\Microsoft BizTalk Server 2004\Developer Tools directory.
- Pull in the Microsoft.BizTalk.WfxToXSDGenerator namespace.
- Add the following code to your Main method:
WfxToXSDGenerator gen = new WfxToXSDGenerator();
object warnings = gen.Warnings();
object errors = gen.Errors();
object schemas = gen.ReferencedSchemas();
if(warnings.Length != 0)
Console.WriteLine("Warnings were found:");
for(int i = 0; i < warnings.Length; i++)