XML comment in BizTalk output message
We ran into an issue today when we had to have an XML comment just below the XML declaration in a message we’re producing in our BizTalk 2006 solution. We needed to produce something like the below.
<?xml version="1.0"?> <!-- Comment goes here -->
Our first approach was to create a map in the send port and to have a custom XSLT template in there that added the comment before the whole transformation process started. We actually got this to work but it meant that we had to have a whole new map with a separate XSLT document in the project!
Eventually we found a property called Xml Asm Processing Instructions (highlighted in the figure – click it to view it in original size) on the XML assembly component (used in the standard XMLTransmit pipeline).
We just put the comment as a value in this property and we were done! No new artifacts or code! Just a weird property – typical BizTalk behavior!
There's 2 Comments So Far
June 21st, 2007 at 6:50 pm
Hello! Good Site! Thanks you! nrhrobjnmztcih
March 7th, 2011 at 10:08 am
Here is another method to both add processinginstruction and/or xml comments
First you will need to use an orchestration
Add a message assignment shape and add similar code as bellow
//Add processingInstructions
processingInstructions = System.String.Format(“”,sellerGLN,InvoiceIn.PartyId);
//Add comment
processingInstructions = processingInstructions + System.String.Format(““,InvoiceIn.PartyId,System.String.Format(“{0}”,InvoiceIn.InvoiceDate));
InvoiceOut = InvoiceIn;
InvoiceOut(*) = InvoiceIn(*);
//ANYTHING you put in the XMLNORM.ProcessingInstruction is inserted before the root node and after the xml declaration(s)
//OBS. You must use a XML transmit pipeline in the send port
InvoiceOut(XMLNORM.ProcessingInstructionOption) = 1;
InvoiceOut(XMLNORM.ProcessingInstruction) = processingInstructions;
Now when you send out the message trough a xml transmit pipeline the information will be appended.
Share your thoughts, leave a comment!