Home Page › Forums › BizTalk 2004 – BizTalk 2010 › Hi..I have a challenge with context to be saved to a file on file system
- This topic has 5 replies, 1 voice, and was last updated 9 years ago by
community-content.
-
AuthorPosts
-
-
January 23, 2008 at 7:24 AM #18818
Hello.
I have a project which includes an orchestration in BTS 2006R2, and also I have Try-Catch shapes in it. I desire on Catch to save message and it’s context in two separate files on let’s say C:\temp folder. Is there a nice way to do it ? (not through HAT with MSBTS_TrackedMessageInstance class)
Thnx
-
January 23, 2008 at 8:52 AM #18820
Check out this thread: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2656842&SiteID=1
The BizTalk Operations dll is suppose to be quicker than performing a similar task through WMI
-
January 23, 2008 at 12:59 PM #18821
Thanx for answer. 🙂
I went to the MSDN link you gave me, some of links which where found there are plenty helpful. But.. I have not seen in any place anyone used “In Orchestration” context pooling. Can’t I just build a method which would take as a parameter a message (it’s Xml right?) and somehow using IBaseMessage to take out the context ?
Thanx again.
-
January 23, 2008 at 10:10 PM #18823
You can definitely pass the message back (http://blogs.msdn.com/darrenj/archive/2004/09/29/235719.aspx). I have never tried what you are describing…but it does sound plausable. Please report back whether you were able to get your desired results.
-
January 24, 2008 at 4:35 AM #18829
Hi.
I am so happy now! We have done this!
We get a message from an orchestration “as is” and get it’s context as a separate XML file which is saved in a file system,in a case we get a catch (in an attempt to get as much information about “Dead Message” as we can).
Here is the code :
#region
GetMsgContextFile//a method where we get public static XmlDocument GetMsgContextFile(IBaseMessageContext con)
{
string propName, propNs, propValue;StringBuilder ctxFile = new StringBuilder();
ctxFile.AppendFormat(
“<MessageInfo><ContextInfo PropertiesCount=\”{0}\”>”, con.CountProperties.ToString());for (int i = 0; i < con.CountProperties; i++)
{
propValue = System.Convert.ToString(con.ReadAt(i, out propName, out propNs));
propValue=propValue.Replace(
“<“, “<”);propValue=propValue.Replace(“>”, “>”);
propValue=propValue.Replace(
“\””, “"”);ctxFile.AppendFormat(“<Property Name=\”{0}\” Namespace=\”{1}\” Value=\”{2}\” />”, propName, propNs, propValue);
}
ctxFile.Append(“</ContextInfo></MessageInfo>”);XmlDocument xDoc = new XmlDocument();
xDoc.LoadXml(ctxFile.ToString());
return xDoc;
}
public static XmlDocument CreateContextDoc(XLANGMessage inputMessage)
{
XMessage inputXMessage;
MethodInfo myMethodInfo = inputMessage.GetType().GetMethod(“Unwrap”, BindingFlags.Instance | BindingFlags.NonPublic);inputXMessage = (XMessage)(myMethodInfo.Invoke(inputMessage, null));
Hashtable contextHashTable = inputXMessage.GetContextProperties();IDictionaryEnumerator contextEnumerator = contextHashTable.GetEnumerator();
string propName=string.Empty;
string propNs = string.Empty;string propValue = string.Empty;
XmlQName key;StringBuilder ctxStringBuilder = new StringBuilder();ctxStringBuilder.AppendFormat(“<MessageInfo><ContextInfo PropertiesCount=\”{0}\”>”, contextHashTable.Count.ToString());
while (contextEnumerator.MoveNext())
{
propValue = contextEnumerator.Value.ToString();
key = (XmlQName)contextEnumerator.Key;
propNs = key.Namespace;
propName = key.Name;
//This lines we need ’cause “<“, “>”, and ‘ ” ‘ characters are not displayed well inside of XML (which are attributes : “XML-in-XML”)
propValue = propValue.Replace(“<“, “<”);
propValue = propValue.Replace(
“>”, “>”);propValue = propValue.Replace(“\””, “"”);ctxStringBuilder.AppendFormat(“<Property Name=\”{0}\” Namespace=\”{1}\” Value=\”{2}\” />”, propName, propNs, propValue);
}
ctxStringBuilder.Append(“</ContextInfo></MessageInfo>”);
XmlDocument ctxXDoc = new XmlDocument();
ctxXDoc.LoadXml(ctxStringBuilder.ToString());
//FInal Xml-Document with context only
return ctxXDoc;
}
-
January 24, 2008 at 8:58 AM #18835
Nice work! Glad to hear you got it working the way that you wanted it.
-
-
-
-
-
-
AuthorPosts
- The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.