Compartilhar via


How to programatically retrieve data from BAMPrimaryImport using supportable API

Eventhough there are Portal UI and Excel that would allow you to query and access BAM activity data, it seems that there are some of you who would like to programmatically access/query this data from a custom application.

In BizTalk Server Documentation, currently in its 2006 pre-released version, you will find information on the BAMManagementService API.  (Under Technical Reference | Developers Reference | BizTalk Server 2006 .Net Class Reference | Microsoft.BizTalk.Bam.Webservices.Management ). 

The BamManagementService class is what we are interested. This is a webservice API and you can also see its methods by pointing to the box where Biztalk is installed. (replace localhost with the machine name in the link below). 

https://localhost/BAM/BamManagementService/BamManagementService.asmx

For example, the above GetViewSummaryForCurrentUser would allow you to retrieve all views that the user has access.  And it would allow you to retrieve the activity names from there.  See code example in help doc for this.

Once you have retrieve the activity name, you can then connect to the database and call the views that below to the specific activity. 

Sample code from help doc (some of these are still been updated):

using WS = BamManagementService;

class Program
{
    static void Main(string[] args)
    {
        GetViewSummary();

        Console.WriteLine("Hit Enter when ready.");
        Console.ReadLine();
    }

    static void GetViewSummary()
    {
        // Create a web service proxy object.
        using (WS.BamManagementService managementService = new WS.BamManagementService())
        {
            // BAM Management Web Service requires client to be authenticated.
            // The client must be a member of the BAM Portal Users group.
            managementService.Credentials = System.Net.CredentialCache.DefaultCredentials;

            // Get the list of all BAM views available to the current user.
            WS.ViewSummaryList viewSummaryList = managementService.GetViewSummaryForCurrentUser();

            // Print the info for all views on the screen.
            foreach (WS.ViewSummary viewSummary in viewSummaryList.View)
            {
                Console.WriteLine("View: {0}", viewSummary.Name);
                // Each view is defined on one or more BAM activities.
                foreach (WS.ActivitySummary activitySummary in viewSummary.Activity)
                {
                    // The activity data can be on a different server/database if distributed
                    // BAM infrastructure is deployed.
                    Console.WriteLine("    Activity: {0} {1}",
                        activitySummary.Name,
                        activitySummary.IsRemote ? "[ Remote ]" : "");
                    Console.WriteLine("        Server: {0}", activitySummary.Server);
                    Console.WriteLine("        Database: {0}", activitySummary.Database);
                    Console.WriteLine("        BAM Portal URL: {0}", activitySummary.PortalUrl);

                    // OLAP and Real-time aggregations aggregations can be defined.
                    if (activitySummary.Aggregation != null)
                    {
                        Console.WriteLine("        Aggregations:");
                        foreach (WS.Aggregation aggregation in activitySummary.Aggregation)
                        {
                            Console.WriteLine("            Name: {0} *** Type: {1} *** Cube Name: {2}",
                                aggregation.Name,
                                aggregation.Type,
                                aggregation.CubeName);
                            if (aggregation.PivotView != null)
                            {
                                foreach (WS.PivotView pivotView in aggregation.PivotView)
                                {
                                    Console.WriteLine("                PivotView: {0}", pivotView.Name);
                                }
                            }
                        }
                    }
                }

                Console.WriteLine();
            }

            if (viewSummaryList.PartialResults)
            {
                // Distributed BAM infrastructure is deployed and one of the referenced databases
                // is not accesible.
                Console.WriteLine("One or more of the referenced databases are not available. " +
                    "The given list of views may not be complete.");
            }
        }
    }

Sample Output:

 View: SalesManagerView
    Activity: PurchaseOrder 
        Server: purchasesrv
        Database: BAMPrimaryImport
        BAM Portal URL: https://purchasesrv/BAM
        Aggregations:
            Name: POCube *** Type: OLAP *** Cube Name: POCube
            Name: POByLocation *** Type: RTA *** Cube Name: POCube
    Activity: Shipment [ Remote ]
        Server: shipsrv
        Database: BAMPrimaryImport
        BAM Portal URL: https://shipsrv/BAM
        Aggregations:
            Name: SHCube *** Type: OLAP *** Cube Name: SHCube
            Name: SHByLocation *** Type: RTA *** Cube Name: SHCube

View: SupplyManagerView
    Activity: SupplyOrder 
        Server: purchasesrv
        Database: BAMPrimaryImport
        BAM Portal URL: https://purchasesrv/BAM
        Aggregations:
            Name: SupplyCube *** Type: OLAP *** Cube Name: SupplyCube
                PivotView: SupplyCost
            Name: SupplyTimes *** Type: RTA *** Cube Name: SupplyCube
                PivotView: SupplyTimes

Hit Enter when ready.

Comments

  • Anonymous
    May 31, 2006
    If you have installed BAM (BizTalk Server 2004 or BizTalk Server 2006), you may have noticed that a web...

  • Anonymous
    August 29, 2006
    can we develope our own portal by using these web services.

  • Anonymous
    January 16, 2007
    Hi Amrutha, As long as you use those supported API, there is nothing preventing you from creating custom portal.  Infact one area you might want to consider doing this is extending the view to view other related docs/whatever to an activity.  See AddReference method. Thanks, Keith

  • Anonymous
    August 15, 2007
    If you are interested in the Activity Instances IMO the only really interesting stuff, this web service does not deliver. According to the msdn help on this webservice: "The BAM Portal uses this web service for everything except the activity instance queries. Custom applications can use this web service to avoid working directly with the database. "

  • Anonymous
    August 17, 2007
    Detail information of the activity instances can be retrieved from using all the activity views once you know what the activity names are. When you deploy an activity check all the views that are available for that activities, this allows for much greater flexibility of what you can do. Please post it here to get other perspectives as well: ttp://forums.microsoft.com/MSDN/default.aspx?ForumGroupID=398&SiteID=1

  • Anonymous
    August 22, 2007
    That's not much different from BizTalk 2004 IMO; Our dba has problems with querying the BizTalk database directly, so it's a bit of a disappointment that there is no web interface to query the detail information.