Using Microsoft.BizTalk.ExplorerOM
With the aid of the Microsoft.BizTalk.ExplorerOM library found in "C:\Program Files\Microsoft BizTalk Server 2006\Developer Tools" you can write your own tool for administration of your Biztalk applications. With this API you can have a look at the installed applications, add applications and configure sendports and receivelocations and all other parts of the application.
Start with declaring an object of type BtsCatalogExplorer and giving it the connectionstring to the Biztalk Management database. On this object there is the applications collection as an entry to all the elements of an installed BizTalk application.
After changing the configuration you call the SaveChanges() method to make them permanent. Use RefreshChanges() to reload the latest configuration.
Example 1, just a dump of names of the applications, names of the orchestrations and sendports :
BtsCatalogExplorer btsCatalogExplorer; btsCatalogExplorer = new BtsCatalogExplorer(); btsCatalogExplorer.ConnectionString = "Integrated Security=SSPI;database=BizTalkMgmtDb;server=VS_BIZDEVSQL1";
foreach (Application o in btsCatalogExplorer.Applications) { Console.WriteLine(o.Name); } foreach (BtsOrchestration orch in btsCatalogExplorer.Applications["APP1"].Orchestrations) { Console.WriteLine(orch.FullName); } foreach (SendPort sport in btsCatalogExplorer.Applications["APP1"].SendPorts) { Console.WriteLine(sport.Name); }
_
Example 2, changing the transporttype of a port.
_
BtsCatalogExplorer btsCatalogExplorer; btsCatalogExplorer = new BtsCatalogExplorer(); btsCatalogExplorer.ConnectionString = "Integrated Security=SSPI;database=BizTalkMgmtDb;server=VS_BIZDEVSQL1";
btsCatalogExplorer.Applications["APP1"].SendPorts["ThePort"].Status = PortStatus.Stopped; btsCatalogExplorer.Applications["APP1"].SendPorts["ThePort"].PrimaryTransport.TransportType = btsCatalogExplorer.ProtocolTypes["WCF-NetNamedPipe"]; btsCatalogExplorer.Applications["APP1"].SendPorts["ThePort"].Status = PortStatus.Started;
btsCatalogExplorer.SaveChanges();
Example 3, adding a new application with a receiveport and its receivelocation.
BtsCatalogExplorer btsCatalogExplorer; btsCatalogExplorer = new BtsCatalogExplorer(); btsCatalogExplorer.ConnectionString = "Integrated Security=SSPI;database=BizTalkMgmtDb;server=VS_BIZDEVSQL1";
Application application; application = btsCatalogExplorer.AddNewApplication(); application.Name = "APP1";
btsCatalogExplorer.SaveChanges();
btsCatalogExplorer.Refresh();
application = btsCatalogExplorer.Applications["TestApp"]; ReceivePort receivePort = application.AddNewReceivePort(false); receivePort.Name = "ThePort"; receivePort.Authentication = AuthenticationType.NotRequired; receivePort.RouteFailedMessage = false; receivePort.Description = "test"; ReceiveLocation receiveLocation; receiveLocation = receivePort.AddNewReceiveLocation(); receiveLocation.Name = "TheReceiveLocation"; receiveLocation.ReceivePipeline = btsCatalogExplorer.Pipelines["Microsoft.BizTalk.DefaultPipelines.XMLReceive"]; receiveLocation.ReceiveHandler = btsCatalogExplorer.ReceiveHandlers[1]; receiveLocation.TransportType = btsCatalogExplorer.ProtocolTypes["FILE"]; receiveLocation.Address = @"C:\temp\DROPS\IN";
btsCatalogExplorer.SaveChanges();
