オーケストレーション バインドのサンプルでは、 Microsoft.BizTalk.ExplorerOM 管理オブジェクトを使用してオーケストレーションを構成および管理する方法を示します。
[前提条件]
このサンプルでは、 <Samples Path>\Orchestrations\HelloWorld ディレクトリにある setup.bat を実行して HelloWorld サンプルをデプロイする必要があります。
このサンプルの管理オブジェクトを使用するには、BizTalk Server の管理特権が必要です。
Windows PowerShell スクリプトの例では、スクリプトの実行を許可する Windows PowerShell 実行ポリシーが必要です。 詳細については、「 実行ポリシーの確認」を参照してください。
このサンプルの役割
このサンプルでは、 Microsoft.BizTalk.ExplorerOM 名前空間の管理オブジェクトを使用してオーケストレーションを管理する方法を示します。 このサンプルでは、 ExplorerOM オブジェクトを使用した次の操作を示します。
Microsoft.BizTalk.ExplorerOM.BtsCatalogExplorer クラスを使用して BizTalk 管理データベースに接続する。
Microsoft.BizTalk.ExplorerOM.BtsOrchestration クラスの Status プロパティを変更してオーケストレーションを停止および開始します。
Microsoft.BizTalk.ExplorerOM.BtsOrchestration クラスの Status プロパティを変更して、オーケストレーションの参加と登録解除を行います。
Microsoft.BizTalk.ExplorerOM.BtsOrchestration クラスの Ports コレクションを使用したオーケストレーションのバインドとバインド解除。
このサンプルを検索する場所
サンプルは、次の SDK の場所にあります。
< サンプル パス>\Admin\ExplorerOM\OrchestrationBinding
次の表に、このサンプルのファイルとその目的を示します。
ファイル(複数可) | 説明 |
---|---|
OrchestrationBinding.cs | このサンプルで示されている操作用の Visual C# ソース ファイル。 |
OrchestrationBinding.sln、OrchestrationBinding.csproj、OrchestrationBinding.suo | サンプルのソリューション ファイルとプロジェクト ファイル。 |
このサンプルをビルドする
HelloWorld サンプルをビルドして初期化する手順が完了していることを確認します。 これらの手順は 、HelloWorld (BizTalk Server サンプル) で提供されています。
Visual Studio で、ソリューション ファイル OrchestrationBinding.slnを開きます。
[ビルド] メニューの [ソリューションのビルド] をクリックします。
このサンプルを実行する
コマンド ウィンドウを開き、次のフォルダーに移動します。
< サンプル パス>\Admin\ExplorerOM\OrchestrationBinding\bin\Debug
OrchestrationBinding.exe ファイルを実行し、サンプルの指示に従います。
Windows PowerShell スクリプトの例
次の Windows PowerShell スクリプトを使用して、 ExplorerOM クラスの同じ機能を示すことができます。
注意事項
この例またはガイダンスでは、接続文字列やユーザー名とパスワードなどの機密情報を参照します。 これらの値をコードにハードコーディングしないでください。また、使用可能な最も安全な認証を使用して機密データを保護してください。 詳しくは、次のドキュメントをご覧ください。
Function RefreshPrompt($oldstatus,$newstatus)
{
Write-Host Orchestration Status should now be `"$oldstatus`"
Write-Host Press F5 in the Orchestrations view of BizTalk Server Administration Console to refresh and verify
if ($newstatus)
{
Write-Host Pressing `<Enter`> now will $newstatus the orchestration using ExplorerOM`.`.`.
Read-Host
Write-Host "=== Please wait, attempting to $newstatus the orchestration... ===`r`n"
}
else
{
write-host `r`n
}
}
#===================#
#=== Main Script ===#
#===================#
#=== Make sure the ExplorerOM assembly is loaded ===#
[void] [System.reflection.Assembly]::LoadWithPartialName("Microsoft.BizTalk.ExplorerOM")
#=== Connect to the BizTalk Management database ===#
$Catalog = New-Object Microsoft.BizTalk.ExplorerOM.BtsCatalogExplorer
$Catalog.ConnectionString = "SERVER=.;DATABASE=BizTalkMgmtDb;Integrated Security=SSPI"
#=== This sample expects the HelloWorld sample orchestration to be using the ===#
#=== default name "Biztalk Application 1" ===#
$HelloWorldApp = $Catalog.Applications["Biztalk Application 1"]
$orch = $HelloWorldApp.orchestrations["Microsoft.Samples.BizTalk.HelloWorld.HelloSchedule"]
#==================================================================#
#=== Register a trap handler to discard changes on exceptions ===#
#=== Execution will continue in the event we need to re-enlist, ===#
#=== re-bind, or restart the orchestration. ===#
#==================================================================#
$ErrorActionPreference="silentlycontinue"
trap { "Exception encountered:`r`n"; $_; "`r`nDiscarding Changes and continuing execution...`r`n";$Catalog.DiscardChanges();}
write-host `r`nMake sure the "HelloWorld" sample application is deployed and running.
write-host By default it will be listed in the BizTalk Server Administration Console
write-host with the application name: `"BizTalk.Application.1`"`r`n
#==========================================================#
#=== Change orchestration state from Started to stopped ===#
#==========================================================#
RefreshPrompt Started stop
$orch.Status = [Microsoft.BizTalk.ExplorerOM.OrchestrationStatus] "Enlisted"
$Catalog.SaveChanges()
#=============================================================#
#=== Change orchestration state from stopped to unenlisted ===#
#=============================================================#
RefreshPrompt Stopped unenlist
$orch.Status = [Microsoft.BizTalk.ExplorerOM.OrchestrationStatus] "Unenlisted"
$Catalog.SaveChanges()
#=============================================================#
#=== Change orchestration state from unenlisted to unbound ===#
#=============================================================#
RefreshPrompt Unenlisted unbind
$orch.Ports["SendInvoicePort"].SendPort = $null
$orch.Ports["ReceivePOPort"].ReceivePort = $null;
$orch.Host = $null
$Catalog.SaveChanges()
#==================================================================#
#=== Change orchestration state from unbound back to unenlisted ===#
#==================================================================#
RefreshPrompt Unenlisted`(Unbound`) re-bind
$orch.Ports["SendInvoicePort"].SendPort = $Catalog.SendPorts["HelloWorldSendPort"]
$orch.Ports["ReceivePOPort"].ReceivePort = $Catalog.ReceivePorts["HelloWorldReceivePort"]
$orch.Host = $Catalog.Hosts["BizTalkServerApplication"]
$Catalog.SaveChanges()
#==================================================================#
#=== Change orchestration state from unenlisted back to stopped ===#
#==================================================================#
RefreshPrompt Unenlisted enlist
$orch.Status = [Microsoft.BizTalk.ExplorerOM.OrchestrationStatus] "Enlisted"
$Catalog.SaveChanges()
#===============================================================#
#=== Change orchestration state from stopped back to started ===#
#===============================================================#
RefreshPrompt Stopped restart
$orch.Status = [Microsoft.BizTalk.ExplorerOM.OrchestrationStatus] "Started"
$Catalog.SaveChanges()
RefreshPrompt Started
Windows PowerShell スクリプトの実行からの出力例を次に示します。
PS C:\> .\OrchestrationBind.ps1
Make sure the HelloWorld sample application is deployed and running.
By default it will be listed in the BizTalk Server Administration Console
with the application name: "BizTalk.Application.1"
Orchestration Status should now be "Started"
Press F5 in the Orchestrations view of BizTalk Server Administration Console to refresh and verify
Pressing <Enter> now will stop the orchestration using ExplorerOM...
=== Please wait, attempting to stop the orchestration... ===
Orchestration Status should now be "Stopped"
Press F5 in the Orchestrations view of BizTalk Server Administration Console to refresh and verify
Pressing <Enter> now will unenlist the orchestration using ExplorerOM...
=== Please wait, attempting to unenlist the orchestration... ===
Orchestration Status should now be "Unenlisted"
Press F5 in the Orchestrations view of BizTalk Server Administration Console to refresh and verify
Pressing <Enter> now will unbind the orchestration using ExplorerOM...
=== Please wait, attempting to unbind the orchestration... ===
Orchestration Status should now be "Unenlisted(Unbound)"
Press F5 in the Orchestrations view of BizTalk Server Administration Console to refresh and verify
Pressing <Enter> now will re-bind the orchestration using ExplorerOM...
=== Please wait, attempting to re-bind the orchestration... ===
Orchestration Status should now be "Unenlisted"
Press F5 in the Orchestrations view of BizTalk Server Administration Console to refresh and verify
Pressing <Enter> now will enlist the orchestration using ExplorerOM...
=== Please wait, attempting to enlist the orchestration... ===
Orchestration Status should now be "Stopped"
Press F5 in the Orchestrations view of BizTalk Server Administration Console to refresh and verify
Pressing <Enter> now will restart the orchestration using ExplorerOM...
=== Please wait, attempting to restart the orchestration... ===
Orchestration Status should now be "Started"
Press F5 in the Orchestrations view of BizTalk Server Administration Console to refresh and verify
こちらもご覧ください
Admin-ExplorerOM (BizTalk Server Samples フォルダー)HelloWorld (BizTalk Server サンプル)