|  | 网站首页 | .Net研究 | 
您现在的位置: 程序员之路 >> .Net研究 >> .net应用技术 >> 企业信息化 >> 文章正文
赞助商链接
频 道 导 航
.Net研究频道栏目导航
相 关 文 章
BizTalk Server 2006的三层编程接口           
BizTalk Server 2006的三层编程接口
作者:Springer 文章来源:不详 更新时间:2007-5-10 11:41:11

BizTalk Server 2006的三层编程接口
  BizTalk Server 2006的三层编程接口

       我们知道,微软产品一般都提供三层API供程序员调用C#/C++等高级语言调用的APIWMI和命令行。

       在BizTalk Server 2006中,微软也提供了类似的三层API给我们使用,它们分别是: ExplorerOM, WMIBtsTask.exe/BtsDeploy.exe。下面我们对如何使用三层不同的APIBizTalk Server 中的各类Artifacts进行操控作一个简要介绍。

 一、利用 Microsoft.BizTalk.ExplorerOM;

1.引用Assembly: c:\Program Files\Microsoft BizTalk Server 2006\Developer Tools\microsoft.biztalk.explorerom.dll

2.using Microsoft.BizTalk.ExplorerOM;

3.例如创建一个ReceivePort的代码如下:

         static void CreateReceivePort()

         {

              BtsCatalogExplorer root = new BtsCatalogExplorer();

              try

              {

                   root.ConnectionString = "Server=.;Initial Catalog=BizTalkMgmtDb;Integrated Security=SSPI;";

                   //Create a new one way receive port.

                   ReceivePort myreceivePort = root.AddNewReceivePort(false);

                   //Note that if you do not set the name property of the ReceivePort,

                   //it will use the default name generated.

                   myreceivePort.Name = "My Receive Port";

                   myreceivePort.Tracking = TrackingTypes.AfterReceivePipeline;

                   //Try to commit the changes made so far. If it fails, roll-back

                   //all the changes.

                   root.SaveChanges();

              }

              catch (Exception e)

              {

                   root.DiscardChanges();

                   throw e;

              }

         } 


二、
WMI。利用WMIBizTalk Server 2006Artifacts进行操控:

1.      利用VBScript中的 GetObjectCreateObject Artifacts进行操控:

下面举例Enlist 一个Orchestration:(EnlistOrch.vbs

EnlistOrch

Sub EnlistOrch()

'Get the command line arguments entered for the script

Dim Args: Set Args = WScript.Arguments

 

'error handling is done by explicity checking the err object rather than using

'the VB ON ERROR construct, so set to resume next on error.

on error resume next

'Make sure the expected number of arguments were provided on the command line.

'if not, print usage text and exit.

If (Args.Count < 2) Or (Args.Count > 3) Then

     PrintUsage()

     wscript.quit 0

End If

 

Dim InstSet, Inst, Query, OrchestrationName, AssemblyName, HostName, Start

Dim AutoEnableReceiveLocation: AutoEnableReceiveLocation = 2

Dim AutoResumeOrchestrationInstance: AutoResumeOrchestrationInstance = 2

OrchestrationName = Args(0)

AssemblyName = Args(1)

         

'Check if orchestration is to be started

If (Args.Count = 3) Then

     If ("Start" = Args(2)) Then

          Start = True

     Else

          wscript.echo "Wrong optional flag."

          PrintUsage()

          wscript.quit 0

     End If

End If

'set up a WMI query to acquire a list of defaul inprocess hosts

'This should be a list of zero or one host.

Query = "SELECT * FROM MSBTS_HostSetting WHERE IsDefault =""TRUE"""

Set InstSet = GetObject("Winmgmts:!root\MicrosoftBizTalkServer").ExecQuery(Query)

 

'Check for error condition before continuing.

If Err <> 0 Then

     PrintWMIErrorthenExit Err.Description, Err.Number

End If

 

'if Default Host found, get Host Name and NT Group Name. There is only one default host.

If InstSet.Count > 0 Then

     For Each Inst In InstSet

          HostName = Inst.Name

          If Err <> 0   Then

               PrintWMIErrorthenExit Err.Description, Err.Number

          End If

          wscript.echo "Using default inprocess host " & HostName & "."

     Next

End If

 

'set up a WMI query to acquire a list of orchestrations with the given Name and

'AssemblyName key values. This should be a list of zero or one Orchestrations.

Query = "SELECT * FROM MSBTS_Orchestration WHERE Name =""" & OrchestrationName & """ AND AssemblyName = """ & AssemblyName & """"

[1] [2] [3] [4] 下一页

文章录入:admin    责任编辑:admin 
  • 上一篇文章:

  • 下一篇文章:
  • .Net研究栏目导航
    网站频道导航