2013-10-02 23 views
6

我在業務流程的消息分配形狀內設置元素的值。我正在使用XPATH函數來做到這一點。BizTalk - 在消息分配形狀中的CDATA

該文本需要包含在CDATA部分。這是我想做到這一點:

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

但是,BizTalk逃脫它和元素中的文本最終看起來像這樣:

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

我似乎無法找到對任何事情關於指示BizTalk,我需要一個CDATA部分我的_response字符串。任何人都可以幫忙?

感謝

+1

有你看過這個博客? http://soa-thoughts.blogspot.co.nz/2007/07/cdata-mapping-experience-inside-biztalk.html – Dijkgraaf

+0

謝謝!我實施了類似於文章中所演示的內容;這就是我需要的! – gmang

回答

6

我會回答我的問題,以防有人分擔它正在尋找。這是基於對這個職位: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); 
相關問題