Saturday, May 25, 2013

How to test Map if it has multiple source messages


A nice feature of BizTalk is the possibility to have many-to-one maps. This means that a single map requires multiple input messages and produces a single output message. This type of mapping is often required to support complex message flows.
When you create a map, you see a wizard-like screen in which you have to specify input and outputs message types, as well as the map name. Based on that, BizTalk generates an empty map for you. In case you have specified multiple input message types, BizTalk will generate a single message schema internally. This schema contains references to all input message types.
Testing a many-to-one map might be difficult. The “test map” option of the map allows for only a single input message to be specified. Instead of passing multiple test messages to the test option, you should pass a single message of the (internally used) message definition that was generated based on the individual message types.
This is how you can get hold of the XSD of this generated message definition:
  • Locate the file that contains the many-to-one map, and open it with a text editor.
  • Find the SrcTree tags. Copy all text that is in between the opening and closing tag named SrcTree.
  • Paste the text in a new text document.
  • In the document, you will see tags with names like InputMessagePart_0, InputMessagePart_1, InputMessagePart_2. Those contain the references to individual message types
  • Remember which definition is referenced to under each InputMessagePart_n-section. Then delete the contents of each InputMessagePart_n-section
  • Save the document as a text file, and change the extension to xsd. Take care that the xsd and the many-to-one map are in the same folder
  • Go to VisualStudio, and open your project. Add the new xsd to the project (add existing item), and open it.
  • Go to the Schema-node, properties, imports. Remove the references to the individual message types. Note: do not remove the other imports.
  • Save and close.
  • Using the context menu for this xsd, generate an message instance, and check where it is stored.
  • You have just created an “empty shell“ XML-message. Open this message with a text or XML-editor. Paste your original test messages (for each message type being input to the map) in the proper InputMessagePart_n-section. Do not copy xml-headers, just the plain message
  • Save the file.
This is it: you have created a test message to be used with your many-to-one map as test input. Link the instance to the map, then test it.
If you think that this is a lot of work for simple testing, bear in mind that the alternative is to go through this cycle for each and every small change you need to make to the map:
  • Unenlist the orchestration
  • Undeploy the projects
  • Rebuild the project
  • Deploy the projects
  • Bind the orchestrations
  • Start the orchestrations
  • Go thorugh a test sequence.

No comments:

Post a Comment