Editar

Compartilhar via


BrowsingArtifacts (BizTalk Server Sample)

The BrowsingArtifacts sample demonstrates how to enumerate BizTalk artifacts and attributes.

Prerequisites

  • You must have BizTalk Server administrative privileges to use the administrative objects in this sample.

  • The Windows PowerShell script example requires the Windows PowerShell execution policy to allow script execution. For more information, see about_Execution_Policies.

What This Sample Does

This sample demonstrates using the BtsCatalogExplorer class from the Microsoft.BizTalk.ExplorerOM namespace to enumerate artifacts and report their attributes. The following artifacts are included in the report generated by this sample: Orchestrations, Ports, Assemblies, Parties, and Transforms. This sample is written in Microsoft Visual C#. A Windows PowerShell example script is also provided in this topic.

Where To Find This Sample

The sample is located in the following SDK location:

<Samples Path>\Admin\ExplorerOM\BrowsingArtifacts

The following table shows the files in this sample and describes their purpose.

File(s) Description
BrowsingArtifacts.cs Visual C# source file for operations demonstrated in this sample.
BrowsingArtifacts.sln, BrowsingArtifacts.csproj, BrowsingArtifacts.suo Solution and project files for the sample.

Building and Running This Sample

To build this sample

  1. In Visual Studio, open the solution file BrowsingArtifacts.sln.

  2. On the Build menu, click Build Solution.

To run this sample

  1. Open a command window and navigate to the following folder:

    <Samples Path>\Admin\ExplorerOM\BrowsingArtifacts\bin\Debug

  2. Run the file BrowsingArtifacts.exe.

Windows PowerShell Script Example

The following Windows PowerShell script can be used to demonstrate the same features of the ExplorerOM classes:

Caution

This example or guidance references sensitive information, such as a connection string or a username and password. Never hardcode these values in your code, and make sure that you protect confidential data by using the most secure authentication available. For more information, see the following documentation:

Function EnumOrchestrations($catalog)
{
    Write-Host `r`n======================
    Write-Host ===  ORCHESTRATIONS  ===
    Write-Host ======================`r`n

    #=== Enumerating the assemblies and pulling orchestration information ===#

    foreach($assembly in $catalog.Assemblies)
    {
        foreach($orch in $assembly.Orchestrations)
        {
            #=== We can’t report the host if it is not hosted or enlisted ===#
            if ($orch.Status -ieq "Unenlisted")
            {
                Write-Host Name : $orch.Fullname`r`nHost : N/A`r`nStatus : $orch.Status
            }
            else
            {
                Write-Host Name : $orch.Fullname`r`nHost : $orch.Host.Name`r`nStatus : $orch.Status
            }

            #=== Reporting port types and operations ===#
            foreach($port in $orch.Ports)
            {
                Write-Host "`tPort:"$port.PortType.FullName

                foreach($portop in $port.PortType.Operations)
                {
                    Write-Host "`t`tOperation:"$portop.Name
                }
            }

            #=== Reporting Used roles ===#
            foreach($role in $orch.UsedRoles)
            {
                Write-Host "`tRole:"$role.Name"`("$role.ServiceLinkType"`)"

                foreach($EnlistedParty in $role.EnlistedParties)
                {
                    Write-Host "`t`tParty:"$Enlistedparty.Party.Name
                }
            }

            #=== Reporting implemented roles ===#
            foreach($role in $orch.ImplementedRoles)
            {
                Write-Host "`tRole:"$role.Name"`("$role.ServiceLinkType"`)"
            }

            Write-Host
        }
    }
}

Function EnumOtherArtifacts($catalog)
{
    Write-Host `r`n======================
    Write-Host "===   ASSEMBLIES   ==="
    Write-Host ======================`r`n

    foreach($assembly in $catalog.Assemblies)
    {
        Write-Host $assembly.Name
    }

    Write-Host `r`n======================
    Write-Host "===     HOSTS      ==="
    Write-Host ======================`r`n

    foreach($btshost in $catalog.Hosts)
    {
        Write-Host $btshost.Name"`($($btshost.Type)`)"
    }

    Write-Host `r`n======================
    Write-Host "===    PARTIES     ==="
    Write-Host ======================`r`n

    foreach($party in $catalog.Parties)
    {
        Write-Host $party.Name

        foreach($sendport in $party.SendPorts)
        {
            Write-Host "`tSendPort:"$sendport.Name
        }

        foreach($alias in $party.Aliases)
        {
            Write-Host "`tAlias:"$alias.Name":"$alias.Qualifier"="$alias.Value
        }
    }

    Write-Host `r`n======================
    Write-Host "===   TRANSFORMS   ==="
    Write-Host ======================`r`n

    foreach($transform in $catalog.Transforms)
    {
        Write-Host $transform.FullName":`r`n`t"$transform.SourceSchema.Fullname"==>"$transform.TargetSchema.Fullname`r`n
    }
}

#=== Main Script Body ===#

#=== 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"

#=== All reporting is performed in the following two functions ===#

EnumOrchestrations $Catalog
EnumOtherArtifacts $Catalog

Here is an example of running the Windows PowerShell script along with example output:

PS C:\> .\BrowsingArtifacts.ps1

======================
=== ORCHESTRATIONS ===
======================

Name : Microsoft.BizTalk.Edi.BatchSuspendOrchestration.BatchElementSuspendService
Host : BizTalkServerApplication
Status : Enlisted

Name : Microsoft.BizTalk.Edi.BatchingOrchestration.BatchingService
Host : BizTalkServerApplication
Status : Enlisted

Name : Microsoft.BizTalk.Edi.RoutingOrchestration.BatchRoutingService
Host : BizTalkServerApplication
Status : Enlisted

Name : EAIOrchestrations.EAIProcess
Host : N/A
Status : Unenlisted
        Port: EAIOrchestrations.ReceiveReqType
                Operation: Operation_1
        Port: EAIOrchestrations.SendDeclineType
                Operation: Operation_1
        Port: EAIOrchestrations.SendToERPType
                Operation: Operation_1

Name : B2BOrchestrations.B2BProcess
Host : BizTalkServerApplication
Status : Started
        Port: B2BOrchestrations.ReceivePO_Type
                Operation: Operation_1
        Port: B2BOrchestrations.SendPOConfirmed_Type
                Operation: Operation_1
        Port: B2BSchemas.localhost.Process_.Process
                Operation: ReceivePO
        Port: B2BOrchestrations.ReceiveASN_Type
                Operation: Operation_1
        Port: B2BOrchestrations.ReceiveInvoice_Type
                Operation: Operation_1
        Port: B2BOrchestrations.PortType_PaymentVoucherArchive
                Operation: Operation_1
        Port: B2BSchemas.localhost1.Payment_Service_.Payment_Service
                Operation: ProcessPayment
        Port: B2BOrchestrations.SendPaymentAck_Type
                Operation: Operation_1

======================
===   ASSEMBLIES   ===
======================

Microsoft.BizTalk.GlobalPropertySchemas
Microsoft.BizTalk.DefaultPipelines
Microsoft.BizTalk.Adapter.MSMQ.MsmqAdapterProperties
MQSeries
Microsoft.BizTalk.Hws.HwsPromotedProperties
Microsoft.BizTalk.Hws.HwsSchemas
Microsoft.BizTalk.KwTpm.StsDefaultPipelines
Microsoft.BizTalk.KwTpm.RoleLinkTypes
mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Microsoft.BizTalk.Edi.BaseArtifacts
Microsoft.BizTalk.Edi.EdiPipelines
Microsoft.BizTalk.Edi.BatchingOrchestration
Microsoft.BizTalk.Edi.RoutingOrchestration
Microsoft.BizTalk.Edi.EdiIntPipelines
EAISchemas
EAIOrchestrations
B2BSchemas
B2BOrchestrations
WCFArtifacts
FFDisassemblerWalkthrough
BTSWhitespaceTest

======================
===     HOSTS      ===
======================

BizTalkServerApplication (InProcess)
BizTalkServerIsolatedHost (Isolated)

======================
===    PARTIES     ===
======================

PartyB
        Alias: Organization : OrganizationName = PartyB

======================
===   TRANSFORMS   ===
======================

EAISchemas.FFRequestDeniedMap :
         EAISchemas.FlatFileSchema1 ==> EAISchemas.RequestDenied

EAISchemas.RequestDeniedMap :
         EAISchemas.Request ==> EAISchemas.RequestDenied

B2BSchemas.InvoiceToPayment :
         B2BSchemas.CommonInvoice ==> B2BSchemas.localhost1.Reference

B2BSchemas.MapToCommonPO :
         B2BSchemas.PO ==> B2BSchemas.localhost.Reference

BizTalkArtifacts.ConcatMap :
         BizTalkArtifacts.InputSchema ==> BizTalkArtifacts.OutputSchema

FFDisassemblerWalkthrough.Map1 :
         FFDisassemblerWalkthrough.Body ==> FFDisassemblerWalkthrough.Body

BTSWhitespaceTest.Map1 :
         FFDisassemblerWalkthrough.Body ==> BTSWhitespaceTest.Schema1

See Also

Admin-ExplorerOM (BizTalk Server Samples Folder)