r***@gmail.com
2007-05-07 13:54:07 UTC
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 });
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 });