Geeks With Blogs
El Grego BizTalk blog
For a couple of years I have been tracking message-bodies inside BAM but only recently I was asked to make a BAM Portal document link to these message bodies that actually works :-)
Strangely enough I couldn't find any solution on Google so I tried to figure this one out myself. Guess what? I had to jump through quite a few hoops. I decided to share those hoops with my other 2 blog readers (yes you).


  • Hoop 1: the 1st and most obvious step is getting the message bodies into the BAM tables using the eventstreams. This can be done using the AddReference method. 

es.AddReference(activityName, activityID, referenceType, referenceName, referenceData, longReferenceData);


Put the body string inside longReferenceData and freely choose your referenceType and referenceName. Making referenceType unique comes in handy later because you can query on a specific referenceType thru the web service (and not on referenceName).   

You should now have your body inside the BAM table (check: bam_{activityName}_AllRelationships). You can easily query his table via the BAM Management web service like this:

web service










  • Hoop 2: You need to find a way to query the BAM management web service for a specific reference through a simple link instead of a http post soap request.

Jesus and Joe's great BAM paper suggest a restful API which sounds great but unfortunately isn't a fact yet. My workaround consists of httpget-enable the web service. Adding this snippet inside the system.web section of the web.config file in the folder C:\Program Files\Microsoft BizTalk Server 2006\BAMPortal\BAMManagementService will get you exactly that:

    <webServices>
        <protocols>
            <add name="HttpGet"/>
        </protocols>
    </webServices>

Now the web service sample invoke page will also show a sample 'get' request:

asmx sample











  • Hoop 3: You need to put a link to the http get url as a 'document link'  on the BAM portal. You can do this again via the stream by adding a reference of type 'DocumentUrl'  and putting the relative link inside the referenceData field.

es.AddReference(activityName, activityID,
'DocumentUrl', referenceName, referenceData, "");
My link string format looks like this:

string link =
            string.Format(
            "/bam/bammanagementservice/bammanagementservice.asmx/GetReferences?viewName={0}&activityName={1}&activityInstanceId={2}&referenceType={3}",
            "put your activity view name here",
            "put your activity view name here",
            "activityID here",
            "referenceName here");



That's about it.
Posted on Thursday, May 28, 2009 3:02 PM BizTalk - EAI - B2B | Back to top


Comments on this post: BAM Portal Related Document Links That Actually Work

# re: BAM Portal Related Document Links That Actually Work
Requesting Gravatar...
good article, i've had the same problem for years!
Left by adamgump on Jun 30, 2009 6:25 PM

# re: BAM Portal Related Document Links That Actually Work
Requesting Gravatar...
This doesn't work anymore in BT 2009

Anty idea's, this time we have to add the last parameter..... the one that is now ""
Left by Patrick Wellink on Sep 16, 2009 2:54 PM

# re: BAM Portal Related Document Links That Actually Work
Requesting Gravatar...
My fault i forgot about the second hoop, I added that one and now it works. Sorry to bother you
Left by Patrick Wellink on Sep 16, 2009 4:04 PM

# re: BAM Portal Related Document Links That Actually Work
Requesting Gravatar...
No bother. Glad it was of use. Your audit trail app looks really nice too.
Left by Grego on Sep 17, 2009 2:37 AM

# re: BAM Portal Related Document Links That Actually Work
Requesting Gravatar...
Excellent article. I guess, the following sample source code may give further clarity.

v_MessageTobeLogged = m_SourceCustomer.MP_GetFullCustomerResponse;

v_ActivityId = StreamHelper.HelperFunctions.GetNewGUID();
v_Link = System.String.Format(
"/bam/bammanagementservice/bammanagementservice.asmx/GetReferences?viewName={0}&activityName={1}&activityInstanceId={2}&referenceType={3}",
"CustSyncVw",
"ProcessCustomer",
v_ActivityId,
"MsgBody");

Microsoft.BizTalk.Bam.EventObservation.OrchestrationEventStream.BeginActivity("ProcessCustomer",v_ActivityId);
Microsoft.BizTalk.Bam.EventObservation.OrchestrationEventStream.UpdateActivity("ProcessCustomer",v_ActivityId,
"CustomerName", m_SourceCustomer(BulkLoadCustomer.PropertySchema.CustomerName)
);
Microsoft.BizTalk.Bam.EventObservation.OrchestrationEventStream.AddReference("ProcessCustomer",v_ActivityId,"MsgBody","Customer Message",System.DateTime.Now.ToString(),v_MessageTobeLogged.OuterXml);
Microsoft.BizTalk.Bam.EventObservation.OrchestrationEventStream.AddReference("ProcessCustomer", v_ActivityId, "DocumentUrl", "Customer Message URL",v_Link);
Microsoft.BizTalk.Bam.EventObservation.OrchestrationEventStream.EndActivity("ProcessCustomer",v_ActivityId);
Left by Sreeni Nutulapati on Nov 18, 2009 5:38 PM

# re: BAM Portal Related Document Links That Actually Work
Requesting Gravatar...
The GetReference method shows the related document in the the xml format where the "actual" document is within the longReferenceData node of the returned reference. Is there a way to view just the actual document directly (ie only the contents of longReferenceData)?
Left by Dipesh A. on May 16, 2010 12:22 AM

# re: BAM Portal Related Document Links That Actually Work
Requesting Gravatar...
I have created an interceptor in BAM that will enable viewing of original messages in "readable format" (eg: html documents will retain all formatting when view via the BAM portal) instead of raw XML displayed in the browser.

Get in touch with me incase you would like to try out the custom BAM interceptor.
Left by Dipesh A. on Nov 21, 2012 10:41 PM

Your comment:
 (will show your gravatar)


Copyright © Gregory Van de Wiele | Powered by: GeeksWithBlogs.net