Getting XML body and context from tracking



Hi,

The question on how to get hold of the XML data from tracking database
(we're then talking about both the XML body and the XML context) gets
asked over and over again without being answered ... A while a ago
Niriven answered on how to decompress the actual message body from the
BizTalkDTADb (see link at the end of this message). As the XML is
compressed the clue is to use a
Microsoft.BizTalk.Message.Interop.CompressionStreams.Decompress method
from the Microsoft.BizTalk.Pipeline.dll - I've tried it and it works
like charm. The only thing to think of is that the CompressionStreams
class is internal in BizTalk 2006 (not in 2004 I think) and that one
has to invoke the Decompress method using reflection (I've added the
code for that at the end of this message).

However the decompression does not work on the context of that message
(stored in the imgContext field)! One only gets an exception from the
DecompressSequentialStream method that is called from the Decompress
method (I've pasted the exception for everyone to read). This means
that it's still impossible to get hold of values like the
InterchangeID or ReceiveLocation for the message that lives in the
context of a message but are not directly in own fields within the
BizTalkDTADb.

It is possible to get the XML data using the
MSBTS_TrackedMessageInstance WMI script but this is slow as the script
only support saving messages to file!

So, basically we can decompress and read the message body stored in
the imgPart field (thanks to Niriven and the Reflector tool) but how
on earth are the data in the imgContext field stored! I've tried
reading it like plain the using the encodings I could think of without
success ... Has anyone tried this before and succeed or failed? Any
information is interesting.

Exception when calling the Decompress method with data from the
imgContext field in BizTalkDTADb:
{System.Reflection.TargetInvocationException: Exception has been
thrown by the target of an invocation. --->
System.Runtime.InteropServices.COMException (0x8000FFFF): Catastrophic
failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))
at
Microsoft.BizTalk.Message.Interop.CompressionStreams.DecompressSequentialStream(Stream
rawStream, Stream& compressedStream, UInt32& bytesRead, UInt32&
bytesWritten)
at
Microsoft.BizTalk.Message.Interop.CompressionStreams.Decompress(Stream
stm, UInt32& bytesRead, UInt32& bytesWritten)
at
Microsoft.BizTalk.Message.Interop.CompressionStreams.Decompress(Stream
stm)
--- End of inner exception stack trace ---

Link to post on how to get the XML from the message body:
http://groups.google.se/group/microsoft.public.biztalk.general/browse_thread/thread/599c038807317802/30473829b681de6d?lnk=st&q=imgpart&rnum=3&hl=sv#30473829b681de6d

Code for invoking the
Microsoft.BizTalk.Message.Interop.CompressionStreams.Decompress using
reflection:
Assembly pipelineAssembly = Assembly.LoadFrom(string.Concat(<path to
dll>, @"\Microsoft.BizTalk.Pipeline.dll"));
Type compressionStreamsType =
pipelineAssembly.GetType("Microsoft.BizTalk.Message.Interop.CompressionStreams",
true);
return (Stream)compressionStreamsType.InvokeMember("Decompress",
BindingFlags.Public | BindingFlags.InvokeMethod | BindingFlags.Static,
null, null, new object[] { (object)stream });

.



Relevant Pages

  • Re: Getting XML body and context from tracking
    ... The question on how to get hold of the XML data from tracking database ... Niriven answered on how to decompress the actual message body from the ... method (I've pasted the exception for everyone to read). ...
    (microsoft.public.biztalk.general)
  • Re: Getting XML body and context from tracking
    ... When you select fields which contain message content or context, you can decompress those fields by surrounding them with functions I designed. ... The question on how to get hold of the XML data from tracking database ... method (I've pasted the exception for everyone to read). ...
    (microsoft.public.biztalk.general)
  • Re: problem with XML DOM load command
    ... with invalid XML and I'm getting suspicious that something in a QFE ... has busted MSXML and its exception processing. ... 2003 Microsoft Corporation. ... >> So this exception is on your main thread where you're doing the load. ...
    (microsoft.public.windowsce.embedded.vc)
  • XML Verarbeitung
    ... Ich möchte eine XML Datei in ein DataSet einlesen und in einem DataGrid ... An unhandled exception occurred during the execution of the ... Please review the stack trace for more information about ...
    (microsoft.public.de.german.entwickler.dotnet.csharp)
  • Importing XML through .NET Web Service with VBA
    ... I need some guidance regarding importing XML data through .NET Web ... I currently have a spreadsheet that utilizes external ... My solution is to setup a .NET Web Service that makes the calls ...
    (microsoft.public.excel.programming)