Hello, I feel inspired today and I want to talk a little about Microsoft.BizTalk.TypeSystem assembly. Microsoft.BizTalk.TypeSystem provides a more complete set of classes that Microsoft.BizTalk.Reflection assembly. Using the TypeSystem assembly we can perform a complex set of operations over BizTalk elements. This assembly contains a set of classes that represents an abstraction of the most common BizTalk items like: PortTypes, MesageTypes, Messages, Schemas, etc. In this post I want to show specifically how to uses some of these classes to obtain information about BizTalk elements. This post is a continuation of my previous post talking about Microsoft.BizTalk.Reflection.Inside of the Microsoft.BizTalk.TypeSystem assembly we have the Microsoft.BizTalk.MetaDataOM namespace that contains a set of types that represents the fundamental elements of the BizTalk object model. One of the main types is the IBizTalkAssembly interface which abstracts the common elements to the BizTalk compiled assembly. The next code shows how to obtain a reference to IBizTalkAssembly using the path of the BizTalk assembly.


BtsAssemblyManagerClass manager= new BtsAssemblyManagerClass();



The BtsAssemblyManager’s class is located in the BtsMetaDataOM assembly. Following the line of my post talking about reflection I want to show some code about how to deal with BizTalk elements. The next code shows how to iterate over the list of orchestration contained in the assembly.


IEnumerator OrchestrationList= CurrentBtsAssembly.Orchestrations;



  Microsoft.BizTalk.MetaDataOM.IBizTalkOrchestration CurrentOrchestration=  (Microsoft.BizTalk.MetaDataOM.IBizTalkOrchestration)OrchestrationList.Current;




The code showed can be used to deal with other BizTalk elements like: MessageTypes, PipeLines, etc.

A similar example shows the same operation but iterating over the Schemas collection and printing the schema’s code.


IEnumerator SchemaList= CurrentBtsAssembly.Schemas;



  Microsoft.BizTalk.MetaDataOM.IBizTalkSchema CurrentSchema=






Using this assembly we can obtain almost all the information of the BizTalk elements present in an assembly. The following function iterates over the Operations of a PortType and prints the name and communication pattern of each one.


public void OperationTest(Microsoft.BizTalk.MetaDataOM.IBizTalkPortType TargetPortType)


  IEnumerator OperationList= TargetPortType.Operations;

  string msg= "";



    Microsoft.BizTalk.MetaDataOM.IBizTalkOperation CurrentOperation= 




            Console.WriteLine("Communication Pattern: Oneway");


            Console.WriteLine("Communication Pattern: RequestResponse");




We can mix the functionality of the TypeSystem assembly with other BizTalk-based assemblies to develop more complex applications. In the example below we use the TypeSystem and Microsoft.XLANGs.BaseTypes assemblies to obtain the Xml Schema of each Xsd part of the MesageTypes in an assembly.


public void MessageTypeTest()


  IEnumerator MsgTypeList= CurrentBtsAssembly.MessageTypes;



    Microsoft.BizTalk.MetaDataOM.IBizTalkMessageType CurrentMsgType= (Microsoft.BizTalk.MetaDataOM.IBizTalkMessageType)MsgTypeList.Current;          

    if(CurrentMsgType != null)




       IEnumerator MsgPartList= CurrentMsgType.Parts;



         Microsoft.BizTalk.MetaDataOM.IBizTalkMessagePart CurrentMsgPart= (Microsoft.BizTalk.MetaDataOM.IBizTalkMessagePart)MsgPartList.Current; 

         if(CurrentMsgPart.Category == Microsoft.BizTalk.MetaDataOM.MessagePartCategory.eMPSchemaRoot)







public void MesagePartTest(Microsoft.BizTalk.MetaDataOM.IBizTalkMessagePart targetpart)


/* CurrentNetAssembly is an instance of System.Refelction.Assembly that represents

    the compiled BziTalk assembly.*/



  string PartTypeName= targetpart.WrapperType;

  Type PartType= CurrentNetAssembly.GetType(PartTypeName);

  MethodInfo info= PartType.GetMethod("get_PartSchema");

  SchemaBase PartSchema= (SchemaBase)info.Invoke(null, null);

  XmlSchemaCollection SchemaList= PartSchema.SchemaCollection;

  foreach(XmlSchema sch in SchemaList)


   MemoryStream mstr= new MemoryStream();


   mstr.Position= 0;

   Byte[] buffer= mstr.GetBuffer();





In BizTalk Server 2004 exists three fundamental types of messages: MultiPart, Xsd and DotNet. The Xsd and DotNet messages are MultiPart messages with a single part. The type of each part of a MessageType can be an Xsd schema, a .NET type or another multipart MessageType. The Category property of a MessagePart indicates the type of the part. In the MesagePartTest method we first obtain the Part’s WrapperType that is the type’s name of the part in the compiled assembly. Next we obtain the Part’s type and invoke the get_PartSchema method that returns a SchemaBase instance. And finally we print each schema presents in the SchemaBase object. I hope that you have enjoyed the examples in this post. I will continue talking of Microsoft.BizTalk.TypeSystem assembly in next posts.

No Comments