gpt4 book ai didi

xml - BizTalk - 消息分配形状中的 CDATA

转载 作者:数据小太阳 更新时间:2023-10-29 01:51:02 26 4
gpt4 key购买 nike

我在编排的消息分配形状内设置元素的值。我正在使用 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);

关于xml - BizTalk - 消息分配形状中的 CDATA,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19140272/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com