If you have installed BAM (BizTalk Server 2004 or BizTalk Server 2006), you may have noticed that a web service called the “BAM Query Service” got installed.
As its name hints, this web service allows the BAM Portal to retrieve BAM instance data without connecting directly to a SQL server.
This web service is intended to be called by the BAM Portal only. Therefore, it is not documented and Microsoft will not support code which makes direct calls to this web service.
A long time ago, when we designed BAM for BizTalk Server 2004, we knew we wanted to get data without connecting to SQL server directly. Unfortunately, we did not have the time to provide a robust, well designed, general purpose set of APIs to query BAM instance data so we settled for a private API which served our immediate needs. It was believed that we would have time in a next release to think about this again and perhaps expose well designed APIs for BAM instance data retrieval. Alas, it was on the list but did not make the cut for BizTalk 2006.
The supported way of retrieving BAM instance data is documented on MSDN (link updated 09/18/2007). Essentially, you need to connect to the SQL server hosting BAM and query the following view (available within the BAM Primary Import Database):