Geeks With Blogs
Jan Schepens Software Developer
I've been searching for a while now on a way to retrieve message body and context from BizTalk without having to use WMI,
simply because I didn't want to write my messages to file, read them back in, parse the context and then delete the generated
files again.

Interesting blog post I stumbled upon was this: View post

But this was not sufficient, because no one managed to get the FULL message context from this method. However, there is a very easy way to do this.

First of all, I defined two strings representing a property name, and a property namespace. They will be the out values for our method.
Now the Context object we get from the tracked message out of the BizTalk Operations dll, implements the Microsoft.BizTalk.Message.Interop.IBaseMessageContext interface. When you look closely at it's methods, you will see a "ReadAt" method. That's the one we need to use.
The Context object also contains a CountProperties variable, which doesn't need any further explanation I think.
So the next part is pretty straight-forward right?
Loop through the CountProperties values, use them as indexes, and call the ReadAt(index, name, namespace) method
for every loop passage, and hold the property value in another string variable.

                string sname = "";
                string snamespace = "";

                for (int i = 0; i < imsg.Context.CountProperties; i++)
                    string value = imsg.Context.ReadAt(i, out sname, out snamespace).ToString();
                    Console.WriteLine(sname + " (" + snamespace + ") = " + value);

And there you have it! Full message context!
Enjoy experimenting with this very cool way of getting body and context of a BizTalk message! IMHO, this is a much better
approach than the WMI way. Posted on Thursday, April 3, 2008 2:01 PM | Back to top

Comments on this post: Easily retrieving message body AND context from BizTalk tracking database

# re: Easily retrieving message body AND context from BizTalk tracking database
Requesting Gravatar...
As AerospaceMango says though, there is plenty of enjoyment to be had from just riding out in the countryside, you don't need all the kit & lessons if you don't want them.

Left by lacoste Polo Shirts on Jun 10, 2011 10:19 PM

Your comment:
 (will show your gravatar)

Copyright © Jan Schepens | Powered by: