BizTalk - CDATA Message Assignment Form

I set the value of the element inside the message assignment form for Orchestration. For this I use XPATH .

The text should be contained within the CDATA section. Here is how I tried to do this:

xpath(messageOut, "//Envelope/Body/MsgFFmt") = @"<![CDATA[" + _response + @"]]>"; 

However, BizTalk eludes him, and the text inside the element looks like this:

 <MsgFFmt>&lt;![CDATA[response content goes here]]&gt;</MsgFFmt> 

I cannot find anything on the Internet regarding BizTalk's indication that I need a CDATA section around the _response line. Can anybody help?

thanks

+6
source share
1 answer

I will answer my question to share it if someone looks. This was based on this post: http://soa-thoughts.blogspot.co.nz/2007/07/cdata-mapping-experience-inside-biztalk.html

I ended up creating a Helper class:

 public class MessageHelper { /// <summary> /// Sets a CDATA section in a XLANG message. /// </summary> /// <param name="message">The xlang message.</param> /// <param name="xPath">The xpath for the element which will contain the CDATA section.</param> /// <param name="value">The contents of the CDATA section.</param> /// <returns>The resulting xml document containing the CDATA section</returns> public static XmlDocument SetCDATASection(XLANGMessage message, string xPath, string value) { if (message == null) throw new ArgumentNullException("message"); if (message[0] == null) throw new ArgumentNullException("message[0]"); var xmlDoc = (XmlDocument)message[0].RetrieveAs(typeof(XmlDocument)); var cdataSection = xmlDoc.CreateCDataSection(value); var node = xmlDoc.SelectSingleNode(xPath); if(node !=null) { node.InnerText = String.Empty; node.AppendChild(cdataSection); } return xmlDoc; } } 

So you call it from the form after the DLL was GAC:

 MessageOut = MessageHelper.SetCDATASection(MessageOut, "/Envelope/Body/MsgFFmt", _string); 
+6
source

Source: https://habr.com/ru/post/955113/


All Articles