Hi..I have a challenge with context to be saved to a file on file system

Home Page Forums BizTalk 2004 – BizTalk 2010 Hi..I have a challenge with context to be saved to a file on file system

Viewing 1 reply thread
  • Author
    Posts
    • #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

    • #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

      • #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.

        • #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.

          • #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(

            “<“, “&lt;”);propValue=propValue.Replace(“>”, “&gt;”);

            propValue=propValue.Replace(

            “\””, “&quot;”);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(“<“, “&lt;”);

            propValue = propValue.Replace(

            “>”, “&gt;”);propValue = propValue.Replace(“\””, “&quot;”);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;

            }

             

             

             

             

            • #18835

              Nice work!  Glad to hear you got it working the way that you wanted it.

Viewing 1 reply thread
  • The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.