Re: Getting XML body and context from tracking



Hi Richard,

Based on an article from Thiago Almeida I wrote a tool that decompresses Message content and context, see the following link:
http://biztalkia.blogspot.com/2010/12/c-solution-to-decompress-biztalk.html

Thiago's article: http://connectedthoughts.wordpress.com/2008/04/02/3-ways-of-programatically-extracting-a-message-body-from-the-biztalk-tracking-database/

It's on CodePlex as well:
http://btsdecompress.codeplex.com

The tool enables the user to fire sql queries at the MessageBox-database or the Tracking-database. When you select fields which contain message content or context, you can decompress those fields by surrounding them with functions I designed.

I hope you want to try this tool. Feel free to contact me through my blog.

Regards,
Lex


On Monday, May 07, 2021 9:54 AM richard.hallgre wrote:

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 });


On Monday, June 04, 2021 10:33 AM richard.hallgre wrote:

On 7 Maj, 15:54, "richard.hallg...@xxxxxxxxx"
<richard.hallg...@xxxxxxxxx> wrote:

I've finally found a solution this (at least in BizTalk 2006). I've
written a short post on it here.

http://www.webhostingsearch.com/blogs/richard/reading-the-message-body-and-context-from-the-biztalkdtadb-using-operations-library-in-biztalk-2006/

RIchard Hallgren



.



Relevant Pages

  • 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
    ... 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: How do I inflate compressed data from an asynchronous socket?
    ... Do keep in mind that you are still using the thread pool though; you just do it implicitly in this case, ... the exception is being thrown in the middle. ... it seems to me that SharpZipLib ought to provide a mechanism for cleanly dealing with errors on the NetworkStream you pass to it. ... you've tried to decompress data in one shot without having the complete data available to decompress. ...
    (microsoft.public.dotnet.languages.csharp)
  • [bds 2006] Decompress .gz files with zlib unit?
    ... The files are not corrupt -- WinZip was unable decompress them. ... "The exception unknown software exception occurred in the ... bufferSize: Integer; ... bytesRead: Integer; ...
    (comp.lang.pascal.delphi.misc)
  • Re: binary XML ?
    ... OpenOffice already stores its documents as zipped XML.) ... >the whole file to be able to decompress the data. ... >reason why webservers use gzip for compressing HTML-pages on ...
    (comp.text.xml)