我在orchestration的Message Assignment形状中设置元素的值.我正在使用XPATH函数来做到这一点.
该文本需要包含在CDATA部分中.这就是我尝试这样做的方式:
xpath(messageOut,"//Envelope/Body/MsgFFmt") = @"<![CDATA[" + _response + @"]]>";
但是,BizTalk将其转义并且元素内的文本最终看起来像这样:
<MsgFFmt><![CDATA[response content goes here]]></MsgFFmt>
我似乎无法在网上找到关于指示BizTalk我需要围绕我的_response字符串的CDATA部分的任何内容.有人可以帮忙吗?
谢谢
我会回答我自己的问题,以便在有人看的时候分享.这是基于这篇文章:
http://soa-thoughts.blogspot.co.nz/2007/07/cdata-mapping-experience-inside-biztalk.html
我最终创建了一个Helper类:
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; } }
MessageOut = MessageHelper.SetCDATASection(MessageOut,"/Envelope/Body/MsgFFmt",_string);
原文地址:https://www.jb51.cc/xml/292098.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。