Martijn's blog - E-Commerce, EAI, BizTalk and .NET

2005/10/27

Schema instance generator for use within Orchestrations

Ever ran into a situation where you want to initialize an instance of a used schema? Normally, lots of people use a C# method which loads a string into a XmlDocument instance and return that instance to the Orchestration engine. This is all fine and dandy, but what happens if the schema the original instance string was based on is changed?

I've created a little helper class which instantiates an example fragment of a dynamically selected schema (the Schema needs to be deployed ofcourse). It essentially performs the same task as the "Generate Instance" does within Visual Studio, but without the nodes being repeating a number of times and without serializing the instance to disk. It returns a simple XmlDocument instance containing an instance of the specified schema.

Using this class would enable better maintainability of your Orchestrations, as you need not change any code in the Orchestration itself if you refactor your schemas. Ofcourse, if you're adding or removing fields which are used in the Orchestration, you need to update those as you would normally.

It's located here. Comments are very welcomed! Find my e-mail address here

2 Comments:

  • Martijn,
    Nice post. I did something similar, but I used this XmlSampleGenerator from a MSDN sample http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnxmlnet/html/xmlgen.asp
    This way you don't have to use the unsupported DocumentSpec class...

    Cheers

    By Anonymous Anonymous, at 1:36 PM  

  • Hi Gregory, I didn't actually think about support issues when I created the component ;-), but you're point is solid. Nice to hear from you again btw!

    By Blogger Martijn Hoogendoorn, at 8:44 PM  

Post a Comment

<< Home