Querying BAM Data using BAM’s Web Services
Our BizTalk Practice has recently embarked on the endeavor of creating a tracking portal for one of our new BizTalk solution accelerators. One of the initial steps for me was to devise a proof of concept for querying the BAM Database using the two included web services with BAM, BAMManagementService and BAMQueryService. Microsoft does not officially support directly utilizing the two web services, limiting their official use to the BAM Portal exclusively.
If however, you find yourself in need of querying BAM data using the predefined web services, you can use the following:
The first step required before utilizing the web services is to add them as web services in your visual studio project.
Add a web reference and point to your BAM Management Service URL, the default being
Then do the same for BAMQueryService pointing to your BAMQueryService URL, the default being
The following code snippet will call the BAMQueryService for the specified view ‘vw_ProcessTracking’, and activity. The cd 2D array will then contain all of the tracking data present in BAM for that view.
The GetViewColumns method utilizes the BAMManagementService to get a list of the columns present in the specified view.
If you receive the following error, as I originally did, when executing the BAMQueryService web service call, make sure to verify the view name argument of the ‘GetInstanceData’ meothod.
System.Web.Services.Protocols.SoapException: Server was unable to process request. —> Microsoft.BizTalk.Bam.Management.BamManagerException: Failed to list permissions for BAM view. —> Microsoft.BizTalk.Bam.Management.BamManagerException: The dbo.bam_vw_ProcessTracking_AllInstances view does not exist in the BAMPrimaryImport database.
The ‘GetInstanceData’ method expects the view name, activity name, query object, and an integer representing the timeout value. The view name, above shown as ‘vw_ProcessTracking’ is the same view name that appears in the BAM Portal as can be seen below. This is different than what may be seen on MSDN