xml – BizTalk – CDATA的消息分配形状

我在orchestration的Message Assignment形状中设置元素的值.我正在使用XPATH函数来做到这一点.

该文本需要包含在CDATA部分中.这就是我尝试这样做的方式:

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

但是,BizTalk将其转义并且元素内的文本最终看起来像这样:

<MsgFFmt>&lt;![CDATA[response content goes here]]&gt;</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;
    }
}

这是DLL在GAC之后从形状中调用它的方法

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

相关文章

php输出xml格式字符串
J2ME Mobile 3D入门教程系列文章之一
XML轻松学习手册
XML入门的常见问题(一)
XML入门的常见问题(三)
XML轻松学习手册(2)XML概念