Infosys Microsoft Alliance and Solutions blog

« Aspiring Software Architect Program | Main | VS 2008 Beta 2 VPC Expiring on 1st Nov 2007 »

BizTalk Assembly - Under the hood

For some work I was doing with BizTalk 2006, I had used reflection and played around with internals of BizTalk Assembly. With BizTalk 2006 R2 now available, I decided to give the code I was working then, a try again.

I have earlier blogged about installing BizTalk 2006 R2 on my Vista machine and as part of that I had built the CallOrchestartion SDK Sample. I decided to work with this sample code itself.

Before going ahead, a word of caution: The internals of BizTalk Assembly aren't published and are subject to change. Hence any code (like below) that you write assuming the internals, may break with future versions.

Let's see how we can load a BizTalk Assembly and find out if it contains an Orchestration or not. For this, we write the regular reflection code as below

            Assembly al = Assembly.LoadFile(@"C:\Program Files\Microsoft BizTalk Server 2006\SDK\Samples\Orchestrations\CallOrchestration\bin\Development\CallOrchestration.dll");

BizTalk Orchestartions derive from BTXService base class. So we search for it as below

            Type orc = null;

            BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static ;


            Type[] types = al.GetTypes();


            foreach (Type t in types)


                if (t.BaseType.Name == "BTXService")


                    orc = t; //t.FullName will give the name of the orchestration



            if (orc == null)


                //no orchestartion. act accordinly



Assuming we get the Orchestration, there are two key fields in the orchestration that contain all the information about it. There is a field called _symInfo that contains information about all the shapes (including children) and the messages used in the orchestartion. There is another field called _symODXML, which contains all the relevant properties for the shapes in the orchestration. Both of these are XML content and you can load and parse them using XML DOM APIs. To load them, something like following will work

            FieldInfo info = orc.GetField("_symInfo", flags);

            string syminfoString = info.GetRawConstantValue().ToString();


            FieldInfo odXML = orc.GetField("_symODXML", flags);

            string odxmlString = odXML.GetRawConstantValue().ToString();

 Note that the odXML content uses a namespace - "xmlns:om=''" and hence when working with the XML, you will need to add the appropriate namespace before firing any XPATH queries.

            XmlNamespaceManager namespMgr = new XmlNamespaceManager(doc.NameTable);

            namespMgr.AddNamespace("om", "");

(where doc is the XmlDocument object).

As important feature of BizTalk that will help understand the XML structure better and get to see the source code of BizTalk Ochestration is the ability to generate the C# files. Refer to this blog for more details on it.

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

Please key in the two words you see in the box to validate your identity as an authentic user and reduce spam.

Subscribe to this blog's feed

Follow us on

Blogger Profiles

Infosys on Twitter