Mapping <Any>-Elements in a BizTalk-Map is not possible. You can not draw a direct connect from or to <Any>-Elements.
Some sources in the web describe the possibility to use a scripting-functoid with a special XSLT to do that, other sources recommand to write a special .NET-component to insert the wished tree under the <Any>-Element.
My way use the XmlDocument.ImportNode()-method to do that. The need for me was to create a message wich contains the request to and the response from my own adapter to trace errors wich occured during the execution of this adapter (adapter writes some business-entities to our intranet-database).
So the messages IntranetDbRequest (msgEai) and IntranetDbResponse (msgIntranetDbResp) should be aggregated to IntranetDbEx.
IntranetDbResponse:
IntranetDbEx:
Because our messages makes extensivly usage of XML-Namespaces we need namespace-managers. Now the XmlNamespaceManager-class dont implements the ISerializable-interface. So we musst drill this class. Since we need this extended XmlNamespaceManager only in one shape, we can do that very simply. Scott Colestock describes that very good in his post Atomic scope abuse. His sample with XmlNode we use also.
The XmlNamespaceManagerEx-class :
Scott Colestocks XmlNodeEx-class:
Now its time for the orchestration.We need a "Construct Message"-shape with a "Transform"- and a "Message Assignment"-shape inside.
The referenced map in the "Transform"-shape only maps the request. This part ist straight forward. The left side ist connected to the right with using the "SHIFT"-key during drawing the connection at the top level.
In the "Message Assignment"-shape is the <Any>-mapping-intelligence:
The last line imports the whole XmlNode from the response-document in the aggregated document.