我在Orchestration的Message Assignment形状中设置元素的值.我正在使用XPATH函数来做到这一点.
该文本需要包含在CDATA部分中.这就是我尝试这样做的方式:
xpath(messageOut, "//Envelope/Body/MsgFFmt") = @"<![CDATA[" + _response + @"]]>";
Run Code Online (Sandbox Code Playgroud)
但是,BizTalk将其转义并且元素内的文本最终看起来像这样:
<MsgFFmt><![CDATA[response content goes here]]></MsgFFmt>
Run Code Online (Sandbox Code Playgroud)
我似乎无法在网上找到关于指示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;
}
}
Run Code Online (Sandbox Code Playgroud)
这是DLL在GAC之后从形状中调用它的方法:
MessageOut = MessageHelper.SetCDATASection(MessageOut, "/Envelope/Body/MsgFFmt", _string);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1944 次 |
| 最近记录: |