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 2) - WMI

- 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:05:12 PM

BTSDeploy

In BizTalk 2004, the BTSDeploy command-line application allowed you to

  • Deploy and remove assemblies from the Management Database.

  • Import and export bindings.

BizTalk 2006 still includes the BTSDeploy tool (minus the BTSDeploy Wizard) for backward compatibility. However, BTSDeploy is now deprecated, and Microsoft recommends converting all scripts or applications to use BTSTask instead of BTSDeploy.

WMI

Windows Management Instrumentation provides a standard way of managing a computer system. WMI allows you to

  • Gather information about systems.

  • Configure systems.

  • Fire or consume specific WMI events occurring on computers or servers.

Tables 11 and 12 describe the different BizTalk WMI classes and events. To utilize these classes, you must use the WMI COM API or the System.Management assembly, which is a .NET COM Interop assembly. Listing 1 demonstrates how to create a host using WMI API from managed code.

Table 11. BizTalk WMI Classes
WMI Class NameSpecific MethodsPurpose
MSBTS_AdapterSettingNoneRegisters new adapters.
Registers new adapters.Deploy, Export, Import, RemoveDeploys/undeploys assemblies and imports/exports binding files.
MSBTS_GroupSettingRegisterLocalServer, UnRegisterLocalServerRepresents information about BTS Groups.
MSBTS_HostStart, StopRepresents a host. Used to start/stop all host instances in a given BizTalk host. It is also used to get/set host properties.
MSBTS_HostInstanceGetState, Install, Start, Stop, UninstallRepresents a host instance. Used Stop, Uninstall to install/uninstall and start/stop a specific host instance in a given BizTalk host.
MSBTS_HostInstanceSettingNoneRepresents host settings.
MSBTS_HostQueueResumeServiceInstancesByID, SuspendServiceInstancesByID, TerminateServiceInstancesByIDResumes, suspends, or terminates service instances.
MSBTS_HostSettingNoneSets host settings.
MSBTS_MessageInstanceSaveToFileRepresents a message instance.
MSBTS_MsgBoxSettingForceDeleteRepresents a single Messagebox setting in the BizTalk Server Group.
MSBTS_OrchestrationEnlist, QueryDependencyInfo, QueryInstanceInfo, Start, Stop, UnenlistRepresents an orchestration. Used to start/stop and enlist/unenlist orchestrations.
MSBTS_ReceiveHandlerNoneRepresents a receive handler. Used to configure receive handlers.
MSBTS_ReceiveLocationDisable, EnableRepresents a receive location. Used to enable and disable the receive location.
MSBTS_ReceiveLocation OrchestrationNoneRepresents all possible combinations of orchestrations and receive locations.
MSBTS_ReceivePortNoneRepresents a receive port. Used to configure receive ports.
MSBTS_SendHandlerNoneRepresents a send handler. Used to configure send handlers.
MSBTS_SendPortEnlist, Start, Stop, UnenlistRepresents a send port. Used to configure send ports.
MSBTS_SendPortGroupEnlist, Start, Stop, UnEnlistRepresents a send port group. Used to start/stop and enlist/unenlist send port groups.
MSBTS_SendPortGroup2 SendPortNoneRepresents a many-to-many relationship between send port groups and send ports.
MSBTS_ServerCheckIfCanInstallHost Instances, Start, StopRepresents a computer within a BizTalk Server Group. Used to start services on a given server.
MSBTS_ServerHostForceUnmap, Map, UnmapRepresents a mapping between BizTalk hosts and host instances. Used to map and unmap relationships.
MSBTS_ServiceInstanceResume, Suspend, TerminateRepresents an instance of a service. Used to resume, suspend, and terminate services.
MSBTS_TrackedMessage InstanceSaveToFileRepresents a tracked message instance saved in the Messagebox or Archive databases. Used to save a message to a file.

Table 12. BizTalk WMI Events
WMI Event NameSpecific PropertiesPurpose
MSTBS_MessageInstance SuspendentEventErrorCategory, ErrorDescription, ErrorId, HostName, Message InstanceID, MessageType, ReferenceType, ServiceClass, ServiceClassID, Service InstanceID, ServiceTypeIDRepresents a suspended event for a BizTalk Message Queuing (MSMQT) message instance
MSTBS_ServiceInstance SuspendentEventErrorCategory, ErrorDescription, ErrorId, HostName, InstanceID, ServiceClass, ServiceClassID,ServiceStatus, ServiceTypeIDRepresents a suspended event for a service instance

Example 1. Create Host Example Using Managed Code
[C#]
using System.Management;

      // Basic WMI operation - Create
     // sample to show MSBTS_HostSetting instance creation
     public void CreateHost(string ServerName, string HostName, int HostType,
string NTGroupName, bool AuthTrusted) { try { PutOptions options = new PutOptions(); options.Type = PutType.CreateOnly; // Create a ManagementClass object and spawn a ManagementObject instance ManagementClass objHostSettingClass = new ManagementClass("\\\\" +
ServerName + "\\root\\MicrosoftBizTalkServer", "MSBTS_HostSetting", null); ManagementObject objHostSetting = objHostSettingClass.CreateInstance(); // Set the properties for the Host objHostSetting["Name"] = HostName; objHostSetting["HostType"] = HostType; objHostSetting["NTGroupName"] = NTGroupName; objHostSetting["AuthTrusted"] = AuthTrusted; // Creating the host objHostSetting.Put(options); System.Console.WriteLine(string.Format("The Host '{0}'has been
created successfully", HostName )); } catch(Exception ex)

{
           System.Console.WriteLine("CreateHost - " + HostName + 
" - failed: " + ex.Message); } }

The same example using VBScript instead of managed code is shown in Listing 2.

Example 2. Create Host Example Using VBScript
[VBScript]
Option Explicit
' wbemChangeFlagEnum Setting
const UpdateOnly = 1
const CreateOnly = 2
Sub CreateHost (ServerName, HostName, HostType, NTGroupName, AuthTrusted)
   On Error Resume Next
   Dim objLocator, objService, objHostSetting, objHS

   ' Connects to local server WMI Provider BizTalk namespace
   Set objLocator = Createobject ("wbemScripting.SwbemLocator")
   Set objService = objLocator.ConnectServer(ServerName, 
"root/MicrosoftBizTalkServer") ' Get WMI class MSBTS_HostSetting Set objHostSetting = objService.Get ("MSBTS_HostSetting") Set objHS = objHostSetting.SpawnInstance_ objHS.Name = HostName objHS.HostType = HostType objHS.NTGroupName = NTGroupName objHS.AuthTrusted = AuthTrusted ' Create Host objHS.Put_open_parenthesis_CreateOnly) CheckWMIError wscript.echo "Host - " & HostName & " - has been created successfully" end Sub

Another interesting task you can accomplish with WMI is to subscribe to the MSTBS_MessageInstanceSuspendentEvent and MSTBS_ServiceInstanceSuspendentEvent. Consuming these events will allow you to handle certain situations gracefully in your BizTalk solution. For instance, when a mapping error occurs on a send or receive port, you could decide to send an e-mail to an administrator and automatically terminate the service instance. Listing 3 shows how to subscribe to a WMI event.

Example 3. Subscribing to a BizTalk WMI Event
using System.Management;
static public void ListenForSvcInstSuspendEvent()
 {
     try
     {
       // Set up an event watcher and a handler for the Create 
MSBTS_ServiceInstanceSuspendedEvent event ManagementEventWatcher watcher =
new ManagementEventWatcher( new ManagementScope("root\\MicrosoftBizTalkServer"),
new EventQuery("SELECT * FROM MSBTS_ServiceInstanceSuspendedEvent") ); watcher.EventArrived += new EventArrivedEventHandler(MyEventHandler); // Start watching for MSBTS_ServiceInstanceSuspendedEvent events watcher.Start(); Console.WriteLine("Press enter to quit"); Console.ReadLine(); watcher.Stop(); } catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); } } static public void MyEventHandler(object sender, EventArrivedEventArgs e) { // Print out the service instance ID and error description upon receiving // of the suspend event Console.WriteLine("A MSBTS_ServiceInstanceSuspendEvent has occurred!"); Console.WriteLine(string.Format("ServiceInstanceID: {0}",
e.NewEvent["InstanceID"])); Console.WriteLine(string.Format("ErrorDescription: {0}",
e.NewEvent["ErrorDescription"])); Console.WriteLine(""); }

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