public
Description: BizTalk 2006 library for unit-testing pipelines and custom pipeline components

Loading Saved Messages

As of version 1.2.0.0 of the library, you can now recreate a message directly from the files exported from the BizTalk Admin Console or HAT when you “save” a message instance.

These saved messages typically consist of a main _context.xml file which describes the context properties of the message, as well as the information of each part associated with it. Each part is saved as a separate .out file which is referenced from the _context.xml file.

To load a saved message, use the LoadMessage() method in the MessageHelper class, passing the path to the _context.xml file as an argument. The library will automatically recreate the message context and load the contents of each message part. Here’s an example:


string contextFile = "{a7de5067-bd42-47ee-bdc0-846a2beae691}_context.xml" 
IBaseMessage msg = MessageHelper.LoadMessage(contextFile);

Caveats

There are a couple of significant issues with this feature that you should be aware of:

  1. The saved message files contain a list of all context properties associated with the message. However, it doesn’t specify which properties had been promoted and which were merely written into the context. When loading the message, all properties are just written, but not promoted.
  2. The _context.xml files has no type information associated with context properties. Because of this, all properties are written into the context as strings. This might cause problems if your tests or components expect the value in the context to be of a certain CLR type other than string (such as DateTime or an Int32).
Last edited by tomasr, about 1 month ago
Versions: