Partager via


OrchestrationBinding (exemple BizTalk Server)

L’exemple de liaison d'orchestrations illustre l’utilisation des objets d’administration Microsoft.BizTalk.ExplorerOM pour configurer et gérer les orchestrations.

Conditions préalables

  • Cet exemple nécessite que l’exemple HelloWorld soit déployé en exécutant setup.bat situé dans le < répertoire Samples Path>\Orchestrations\HelloWorld.

  • Vous devez disposer de privilèges d’administration BizTalk Server pour utiliser les objets d’administration dans cet exemple.

  • L’exemple de script Windows PowerShell nécessite la stratégie d’exécution de Windows PowerShell pour autoriser l’exécution de script. Pour plus d’informations, consultez Examen de la stratégie d’exécution.

Ce que fait cet exemple

Cet exemple illustre l’utilisation des objets d’administration dans l’espace de noms Microsoft.BizTalk.ExplorerOM pour gérer les orchestrations. L’exemple illustre les opérations suivantes à l’aide des objets ExplorerOM :

Où trouver cet exemple

L’exemple se trouve à l’emplacement du Kit de développement logiciel (SDK) suivant :

< Chemin des exemples>\Admin\ExplorerOM\OrchestrationBinding

Le tableau suivant présente les fichiers de cet exemple et décrit leur objectif.

Fichier(s) Descriptif
OrchestrationBinding.cs Fichier source Visual C# pour les opérations illustrées dans cet exemple.
OrchestrationBinding.sln, OrchestrationBinding.csproj, OrchestrationBinding.suo Fichiers solution et projet pour l’exemple.

Générer cet exemple

  1. Vérifiez que vous avez effectué les étapes de création et d’initialisation de l’exemple HelloWorld. Ces étapes sont fournies dans HelloWorld (exemple BizTalk Server).

  2. Dans Visual Studio, ouvrez le fichier solution OrchestrationBinding.sln.

  3. Dans le menu Générer, cliquez sur Générer la solution.

Exécuter cet exemple

  1. Ouvrez une fenêtre de commande et accédez au dossier suivant :

    < Chemin des exemples>\Admin\ExplorerOM\OrchestrationBinding\bin\Debug

  2. Exécutez le fichier OrchestrationBinding.exe et suivez les instructions fournies par l’exemple.

Exemple de script Windows PowerShell

Le script Windows PowerShell suivant peut être utilisé pour illustrer les mêmes fonctionnalités des classes ExplorerOM .

Avertissement

Cet exemple ou conseils référence des informations sensibles, telles qu’une chaîne de connexion ou un nom d’utilisateur et un mot de passe. Ne codez jamais en dur ces valeurs dans votre code et veillez à protéger les données confidentielles à l’aide de l’authentification la plus sécurisée disponible. Pour plus d’informations, consultez la documentation suivante :


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

Voici un exemple de sortie de l’exécution du script 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

Voir aussi

Admin-ExplorerOM (dossier d’exemples BizTalk Server)HelloWorld (exemple BizTalk Server)