Logo
programming4us
programming4us
programming4us
programming4us
Home
programming4us
XP
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Windows Phone
 
Windows Server

BizTalk 2006 : Deploying and Managing BizTalk Applications - Administrative Tools (part 3) - ExplorerOM

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
3/28/2012 5:10:04 PM

ExplorerOM

The ExplorerOM object model is a set of classes and interfaces from the ExplorerOM namespace used by BizTalk Explorer to configure applications. You can consider ExplorerOM as an API to the Management Database that allows you to perform application management and configuration tasks. To use it in your .NET applications, you have to add a reference to the [BizTalk Installation directory]\Developer Tools\Microsoft.Biztalk.ExplorerOM.dll assembly. All artifacts in ExplorerOM are stored in collections, and there are three classes hosting collections of artifacts, as listed in Table 13.

Table 13. ExplorerOM Container Classes
classDescription
BtsCatalogExplorerProvides methods and properties to manipulate artifacts at the BizTalk Server Group level
BtsApplicationProvides methods and properties to manipulate artifacts at the BizTalk application level
AssemblyProvides properties to access artifacts at the assembly level

BtsCatalogExplorer Class

This class provides access to all artifacts in the Management Database, regardless of their association with a specific BizTalk application or assembly. You can also use this class to add or remove artifacts from the different collections and then commit changes to the Management Database. This class is the most fundamental, since all ExplorerOM code you write will have one thing in common: instantiating the BtsCatalogExplorer class and setting the ConnectionString property to access the Management Database.

Table 14 lists the properties of the BtsCatalogExplorer class. As you can guess, all these properties except the ConnectionString property are collections of different BizTalk artifacts tored in the Management Database.

Table 14. ExplorerOM Container Classes
Property NameDescription
ConnectionStringConnection string to the Management Database.
ApplicationsRead-only. Returns a collection of applications in the Management Database.This property is specific to BizTalk Server 2006 and absent in BizTalk 2004.
AssembliesRead-only. Returns a collection of deployed assemblies.
CertificatesRead-only. Returns a collection of certificates installed on the computer.
HostsRead-only. Returns a collection of hosts in the Management Database.
PartiesRead-only. Returns a collection of parties in the Management Database.
PipelinesRead-only. Returns a collection of pipelines in the Management Database.
ProtocolTypesRead-only. Returns a collection of protocol types in the Management Database.
ReceiveHandlersRead-only. Returns a collection of receive handlers in the Management Database.
ReceivePortsRead-only. Returns a collection of receive ports in the Management Database.
SchemasRead-only. Returns a collection of schemas in the Management Database.
SendPortGroupsRead-only. Returns a collection of send port groups in the Management Database.
SendPortsRead-only. Returns a collection of send ports in the Management Database.
StandardAliasesRead-only. Returns a collection of standard aliases..
TransformsRead-only. Returns a collection of transforms.

Let's put everything mentioned previously in practice and write a utility that enumerates all send ports in the Management Database and prints out the port name and status as shown in Listing 4.

Example 4. Enumeration of Send Ports
using System;
using System.Text;
using Microsoft.BizTalk.ExplorerOM;

namespace SendPorts
{
    class Program
    {

        static void Main(string[] args)
        {
            EnumerateSendPorts();
            Console.ReadKey();
         }
         public static void EnumerateSendPorts()
         {
             BtsCatalogExplorer catalog = new BtsCatalogExplorer();
             catalog.ConnectionString = "Server=.;Initial Catalog=BizTalkMgmtDb; 
Integrated Security=SSPI;"; foreach (SendPort sendPort in catalog.SendPorts ) { Console.WriteLine("\tPortName:{0},Status:{1}", sendPort.Name, sendPort.Status); } } } }

Alternatively, you can get access to the collections of artifacts exposed by the BtsCatalog- Explorer class by calling the GetCollection method and passing as a parameter values from the CollectionType enumeration. The member names of this enumeration are exactly the same as the names of the properties of the BtsCatalogExplorer class. Listing 5 shows how to print out port names and status using the GetCollection method.

Example 5. Enumeration of Send Ports Using the GetCollection Method
using System;
using System.Text;
using Microsoft.BizTalk.ExplorerOM;

namespace SendPorts
{
    class Program
    {
        static void Main(string[] args)
        {
            EnumerateSendPorts();
            Console.ReadKey();
         }

         public static void EnumerateSendPorts()
         {
             BtsCatalogExplorer catalog = new BtsCatalogExplorer();
             catalog.ConnectionString = "Server=.;Initial Catalog=BizTalkMgmtDb; 
Integrated Security=SSPI;"; SendPortCollection spCollection =
(SendPortCollection)catalog.GetCollection(CollectionType.SendPort); foreach (SendPort sendPort in spCollection) { Console.WriteLine("\tPortName:{0},Status:{1}", sendPort.Name, sendPort.Status); } } } }

The BtsCatalogExplorer class not only allows you to walk through existing artifacts, but also provides methods to add, delete, and configure them and commit changes to the Management Database. Table 15 lists such methods.

Table 15. BtsCatalogExplorer Methods
Method NameDescription
AddNewApplicationCreates and adds a new Application object to the Application collection. Specific to BizTalk Server 2006.
RemoveApplicationRemoves the specified application from Application collection. Specific to BizTalk 2006.
AddNewPartyCreates and adds a new Party object to the Parties collection.
RemovePartyRemoves the specified party from the Parties collection.
AddNewReceivePortCreates and adds a new ReceivePort object to the ReceivePorts collection.
RemoveReceivePortRemoves the specified receive port from the ReceivePorts collection.
AddNewSendPortCreates and adds a new SendPort object to the SendPorts collection.
RemoveSendPortRemoves the specified send port from the SendPorts collection.
AddNewSendPortGroupCreates and adds a new SendPortGroup object to the SendPortGroups collection.
RemoveSendPortGroupRemoves the specified send port group.
SaveChangesCommits all BtsCatalogExplorer object changes to the Management Database.
DiscardChangesDiscards all BtsCatalogExplorer object changes.

The code in Listing 6 shows how to create a send port using the AddNewSendPort method of the BtsCatalogExplorer class.

Example 6. Creating a New Send Port Using the AddNewSendPort Method
using System;
using Microsoft.BizTalk.ExplorerOM

namespace AddSendPort
{

    class Program
    {
        static void Main(string[] args)
        {
           CreateSendPort();

       }

        private static void CreateSendPort()
        {
            // Connect to the BizTalk configuration database
           BtsCatalogExplorer catalog = new BtsCatalogExplorer();
            catalog.ConnectionString = "Server=PROBIZTALK;Initial Catalog= 
BizTalkMgmtDb;Integrated Security=SSPI;";

try
            {
              // Create static one-way send port
               SendPort myStaticOnewaySendPort = 
catalog.AddNewSendPort(false, false); myStaticOnewaySendPort.Name = "PROBiztalkSendPort"; myStaticOnewaySendPort.PrimaryTransport.TransportType =
catalog.ProtocolTypes["HTTP"]; myStaticOnewaySendPort.PrimaryTransport.Address =
"http://DestinationUrl"; myStaticOnewaySendPort.SendPipeline =
catalog.Pipelines["Microsoft.BizTalk.DefaultPipelines.XMLTransmit"]; // Commit changes to BizTalk configuration database catalog.SaveChanges(); } catch (Exception ex) { catalog.DiscardChanges(); } } } }

BizTalk Server 2006 all artifacts must be associated with a BizTalk application. It is important to note that the code in Listing 6 adds a new port and associates it automatically with the current default application. How to associate artifacts with a specific application will be discussed in the next section, which we devote to the Application class.

Application Class

The second class hosting collections of BizTalk artifacts is the Application class. As you can guess, this class provides similar methods and properties as the BtsCatalogExplorer class. The main difference is that the Application class deals with the artifacts belonging to a specific application.

If you want to perform actions on the artifacts belonging to a specific BizTalk application, you have to obtain a reference on the desired application and then use the methods and properties of the Application class listed in Tables 16 and 17.

Table 16. Application Class Properties
Property NameDescription
AssembliesRead-only. Returns a collection of assemblies associated with the application.
BackReferencesRead-only. Returns a collection of applications referencing the application.
BtsCatalogExplorerRead-only. Returns the BtsCatalogExplorer object containing the Application object.
DescriptionGets or sets the application description.
IsConfiguredRead-only. Returns a Boolean value indicating that all orchestrations' ports in the application are bound.
IsDefaultApplicationRead-only. Returns a Boolean value indicating whether or not the application is the default application.
IsSystemRead-only. Returns a Boolean value indicating whether or not the application is the system application.
NameGets or sets the name of the application.
OrchestrationsRead-only. Returns a collection of the orchestrations associated with the application.
PipelinesRead-only. Returns a collection of the pipelines associated with the application.
PoliciesRead-only. Returns a collection of the policies associated with the application.
ReceivePortsRead-only. Returns a collection of the receive ports associated with the application.
ReferencesRead-only. Returns a collection of the applications referenced by the application.
RolesRead-only. Returns a collection of the roles associated with the application.
SchemasRead-only. Returns a collection of the schemas associated with the application.
SendPortGroupsRead-only. Returns a collection of send port groups associated with the application.
SendPortsRead-only. Returns a collection of the send ports associated with the application.
StatusRead-only. Returns the status of the application.
TransformsRead-only. Returns a collection of the maps associated with the application.

Table 17. Application Class Public Methods
Method NameDescription
AddNewReceivePortAdds a new receive port to the ReceivePorts collection
AddNewSendPortAdds a new send port to the SendPorts collection
AddNewSendPortGroupAdds a new send port group to the SendPortGroups collection
AddReferenceAdds a BizTalk application to the References collection
RemoveReferenceRemoves a BizTalk application from the References collection
StartStarts all orchestrations, send ports, and send port groups, and enables all receive locations belonging to this and referenced applications
StopStops all orchestrations, send ports, and send port groups, and disables all receive locations belonging to this and referenced applications

Assuming you have an application named PROBIZTALK Application, the code in Listing 7 shows how you can obtain a reference to this application and to add a send port to it.

Example 7. Adding a New Send Port to a Specific BizTalk Application
using System;
using Microsoft.BizTalk.ExplorerOM

namespace AddSendPort
{
    class Program
    {
        static void Main(string[] args)
        {
            CreateSendPort();

        }

        private static void CreateSendPort()
        {
           // Connect to the BizTalk configuration database
          BtsCatalogExplorer catalog = new BtsCatalogExplorer();
           catalog.ConnectionString = "Server=PROBIZTALK;Initial Catalog= 
BizTalkMgmtDb;Integrated Security=SSPI;"; try { // Get a reference on existing BizTalk Application Application app = catalog.Applications["PROBIZTALK Application"]

// Create static one-way send port
              SendPort myStaticOnewaySendPort = app.AddNewSendPort(false, false);
              myStaticOnewaySendPort.Name = "PROBiztalkSendPort";
              myStaticOnewaySendPort.PrimaryTransport.TransportType = 
catalog.ProtocolTypes["HTTP"]; myStaticOnewaySendPort.PrimaryTransport.Address =
"http://DestinationUrl"; myStaticOnewaySendPort.SendPipeline =
catalog.Pipelines["Microsoft.BizTalk.DefaultPipelines.XMLTransmit"]; // Commit changes to BizTalk configuration database catalog.SaveChanges(); } catch (Exception ex) { catalog.DiscardChanges(); } } } }

If you happened to work with previous versions of BizTalk Server, you are no doubt aware that starting BizTalk solutions was not easy. For example, if one orchestration called another, they had to be started and stopped in the following strict order: called orchestrations first, calling orchestrations last in case of starting, and in reverse order in case of stopping. Not a problem if you only had a few orchestrations, but what if there were dozens of them and they were interdependent? And how about starting dozens or even hundreds of ports one by one manually? Fortunately, BizTalk Server 2006 provides an easy solution. Simply use the Start and Stop methods of the Application class, taking values from the ApplicationStartOption and ApplicationStopOption enumerations as parameters. Available values are listed in Tables 18 and 19.

Table 18. ApplicationStartOption Enumeration
Enumeration ValueDescription
DeployAllPoliciesSpecifies all policies to be deployed
EnableAllReceiveLocationsSpecifies all receive locations to be enabled
StartAllOrchestrationsSpecifies all orchestrations to be started
StartAllSendPortGroupsSpecifies all send port groups to be started
StartAllSendPortsSpecifies all send ports to be started
StartReferencedApplicationsSpecifies all referenced applications to be started
StartAllSpecifies all of the preceding to be enabled and started

Table 19. ApplicationStartOption Enumeration
Enumeration ValueDescription
UndeployAllPoliciesSpecifies all policies to be undeployed
DisableAllReceiveLocationsSpecifies all receive locations to be disabled
UnenlistAllOrchestrationsSpecifies all orchestrations to be unenlisted and stopped
UnenlistAllSendPortGroupsSpecifies all send port groups to be unenlisted and stopped
UnenlistAllSendPortsSpecifies all send ports to be unenlisted and stopped
StopReferencedApplicationsSpecifies referenced applications to be stopped
StopAllSpecifies all of the preceding options

In order to start your application, you can use the code shown in Listing 8.

Example 8. Starting Biztalk Application
using System;
using Microsoft.BizTalk.ExplorerOM;

namespace BTSApplication
{
    class Program
    {

        static void Main(string[] args)
        {
            BtsCatalogExplorer catalog = new BtsCatalogExplorer();
            catalog.ConnectionString = "Server=.;Initial Catalog=BizTalkMgmtDb; 
Integrated Security=SSPI;"; Application app = catalog.Applications["PROBIZTALK Application"] app.Start(StartApplicationOptions.StartAll); } } }

BtsAssembly

The last class we are going to consider in this section is the BtsAssembly. Using the properties of this class listed in Table 20, you can get access to the collections of compiled artifacts contained in the assembly.

Table 20.BtsAssembly Class Properties
Property NameDescription
ApplicationRead-only. Returns the application this assembly is associated with.
BtsCatalogExplorerRead-only. Returns the IBtsCatalogExplorer interface, which represents the database hosting the assembly.
CultureRead-only. Returns the culture of the assembly.
DisplayNameRead-only. Returns the display name of the assembly.
IsSystemRead-only. Indicates whether or not the assembly is system (deployed during Biztalk installation).
NameRead-only. Returns the name of the assembly.
OrchestrationsRead-only. Returns the collection of orchestrations in the assembly.
PipelinesRead-only. Returns the collection of pipelines in the assembly.
PortTypesRead-only. Returns the collection of port types in the assembly.
PublicTokenRead-only. Returns the public token of the assembly.
RolesRead-only. Returns the collection of roles in the assembly.
SchemasRead-only. Returns the collection of schemas in the assembly.
TransformsRead-only. Returns the collection of maps in the assembly.
VersionRead-only. Returns the version of the assembly.

Assuming you have a deployed assembly named BTSOrchestrations, Listing 9 shows how you can print out orchestration names contained in this assembly using properties of the BtsAssembly class.

Example 9. Enumerating Orchestrations
using System;
using System.Text;
using Microsoft.BizTalk.ExplorerOM;

namespace EnumerateOrchestrations
{
    class Program
    {

        static void Main(string[] args)
        {
            EnumerateOrchestrations();
            Console.ReadKey();
        }

public static void EnumerateOrchestrations()
        {
           BtsCatalogExplorer catalog = new BtsCatalogExplorer();
           catalog.ConnectionString = "Server=.;Initial Catalog=BizTalkMgmtDb; 
Integrated Security=SSPI;"; BtsAssembly assembly = catalog.Assemblies["BTSOrchestrations"]; foreach (BtsOrchestration orch in assembly.Orchestrations ) { Console.WriteLine("\tOrchestrationName:{0}", orch.FullName); } } } }

As you see, programming using ExplorerOM is not very complicated. Once you get a fundamental idea how classes representing BizTalk artifacts are related to each other, the rest will be quite straightforward. For the full list of classes and interfaces, please refer to the product documentation.

Other -----------------
- Windows Server 2003 : Windows Server Update Services (part 2) - Using WSUS: On the Client Side
- Windows Server 2003 : Windows Server Update Services (part 1)
- Microsoft SQL Server 2008 R2 : SQL Server Management Studio - Development Tools (part 4)
- Microsoft SQL Server 2008 R2 : SQL Server Management Studio - Development Tools (part 3) - Integrating SSMS with Source Control & Using SSMS Templates
- Microsoft SQL Server 2008 R2 : SQL Server Management Studio - Development Tools (part 2)
- Microsoft SQL Server 2008 R2 : SQL Server Management Studio - Development Tools (part 1)
- Sharepoint 2010 : Reviewing and Troubleshooting Crawls (part 2) - Using Crawl Reports & Diagnostic Logging
- Sharepoint 2010 : Reviewing and Troubleshooting Crawls (part 1) - Using Crawl Logs
- Sharepoint 2010 : Managing Crawls
- Microsoft Lync Server 2010 Monitoring : Installation (part 2) - Installing the Monitoring Server Role
 
 
Top 10
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
 
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server