Navigation

Search

Categories

 
 

On this page

Custom GetContextProperty Functoid

Archive

Blogroll

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

RSS 2.0 | Atom 1.0 | CDF

Send mail to the author(s) E-mail

Total Posts: 21
This Year: 0
This Month: 0
This Week: 0
Comments: 28

Sign In
Pick a theme:

 Friday, March 24, 2006
Friday, March 24, 2006 4:17:47 AM (GMT Standard Time, UTC+00:00) ( )

I have listened many times, how can I get a message context property from a map?  Well, while I was playing with the framework of BizTalk Server 2006 RC I found the way to do a functoid that implements this functionality.  I’ll try to explain how I do it below.

First, I have to know three values:

Message Name: the name of the message that have the context property
Property Name: the name of the context property
Property Namespace: the namespace of the context property

Second, I need to get the segments of the service (orchestration) and check in each segment if the message that I’m looking for is there.  The messages aren’t stored directly in the service; the messages are stored in the segments that exist inside the orchestration.  Normally one orchestration has two segments and one more segment when the orchestration implements compensation; the message normally is stored in the second segment (I really don’t know why the segments exist, this is an internal architecture from Microsoft and there isn’t information about that).

Third, when I find the particular message I check the context property (formed by Property Name and Property Namespace) inside the message and return its value.

This is the code that I have used:

// set the property
string property = "";
// get the service
Microsoft.XLANGs.Core.Service s = Microsoft.XLANGs.Core.Service.RootService;
foreach (Microsoft.XLANGs.Core.Segment seg in s._segments)
{
// find the real name of the message
foreach (DictionaryEntry de in Microsoft.XLANGs.Core.Context.FindFields(typeof(Microsoft.XLANGs.BaseTypes.XLANGMessage), seg.ExceptionContext))
{
// check that the key ends with the name of the message
if (de.Key.ToString().EndsWith(val1))
{
// get the message as a XLANGMessage
Microsoft.XLANGs.Core.XMessage msg = de.Value as Microsoft.XLANGs.Core.XMessage;
// if the message was found, then I get the value of the property
if (msg != null)
{
// create a XmlQName instance
Microsoft.XLANGs.BaseTypes.XmlQName qName = new Microsoft.XLANGs.BaseTypes.XmlQName(val2, val3);
// find the message property in the message
if (msg.GetContextProperties().ContainsKey(qName))
{
// get the property from GetContextProperties
property = msg.GetContextProperties()[qName].ToString();
}
else if (msg.GetContentProperties().ContainsKey(qName))
{
// get the property from GetContentProperties
property = msg.GetContentProperties()[qName].ToString();
}
}
break;
}
}
if (property.Length > 0)
break;
}
// return the property value
return property;

Exception :(

Unfortunately this functoid ONLY works if it is invoked from an orchestration… I mean a map inside an orchestration.  The reason is simple, to access to Message I have to get the current context of the service and this service is represented by the orchestration, if the orchestration doesn’t exist I cann’t get the context.

You can download the functoid assembly from GetContextProperty Functoid Workspace

This functoid was developed with the framework of Microsoft BizTalk 2006 RC using the Microsoft.XLANGs.Engine.dll and Microsoft.XLANGs.BasTypes.dll assemblies.  I hope that this functionality exists in the RTM version.