Compartir a través de


OrchestrationBinding (ejemplo de BizTalk Server)

En el ejemplo de enlace de orquestación se muestra el uso de los objetos administrativos de Microsoft.BizTalk.ExplorerOM para configurar y administrar las orquestaciones.

Requisitos previos

  • Este ejemplo requiere que el ejemplo HelloWorld se implemente ejecutando setup.bat ubicado en el < directorio Samples Path>\Orchestrations\HelloWorld.

  • Debe tener BizTalk Server privilegios administrativos para usar los objetos administrativos de este ejemplo.

  • El ejemplo del script de Windows PowerShell requiere que la directiva de ejecución de Windows PowerShell permita la ejecución de scripts. Para obtener más información, vea Examinar la directiva de ejecución.

Descripción del ejemplo

En este ejemplo muestra cómo usar los objetos de administración en el espacio de nombres Microsoft.BizTalk.ExplorerOM para administrar las orquestaciones. En el ejemplo se muestran las siguientes operaciones con los objetos ExplorerOM :

Dónde encontrar este ejemplo

El ejemplo se encuentra en la siguiente ubicación del SDK:

<Ruta de acceso de> ejemplos\Administración\ExplorerOM\OrchestrationBinding

En la tabla siguiente se enumeran los archivos del ejemplo y se describe su propósito.

Archivos Descripción
OrchestrationBinding.cs Archivo de código fuente de Visual C# para las operaciones mostradas en este ejemplo.
OrchestrationBinding.sln, OrchestrationBinding.csproj, OrchestrationBinding.suo Archivos de solución y proyecto para el ejemplo.

Compilación de este ejemplo

  1. Asegúrese de haber completado los pasos para crear e inicializar el ejemplo HelloWorld. Estos pasos se proporcionan en HelloWorld (BizTalk Server Sample).

  2. En Visual Studio, abra el archivo de solución OrchestrationBinding.sln.

  3. En el menú Compilar , haga clic en Compilar solución.

Ejecutar esta muestra

  1. Abra una ventana de comandos y desplácese a la siguiente carpeta:

    <Ruta de acceso de> ejemplos\Administración\ExplorerOM\OrchestrationBinding\bin\Debug

  2. Ejecute el archivo OrchestrationBinding.exe y siga las instrucciones que proporciona el ejemplo.

Ejemplo de un script de Windows PowerShell

El siguiente script de Windows PowerShell se puede usar para mostrar las mismas características de las clases 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

A continuación se proporciona el resultado de la ejecución del script de 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

Consulte también

Administración-ExplorerOM (carpeta de ejemplos de BizTalk Server)HelloWorld (ejemplo de BizTalk Server)