Send message of System.String is wrapping xml

让人想犯罪 __ 提交于 2019-12-13 19:30:21

问题


I have a simple odx that constructs a message of type System.String, then pushes out through a send port.

The content of the output message is good except it's prefixed with:

<?xml version="1.0"?>
<string>

e.g.

<?xml version="1.0"?>
<string>
Good plain text format here

How can I prevent the content being wrapped with the without having to resort to a custom pipeline component?


回答1:


Write the string directly to the XLANGMessage in a helper library (as if you were writing binary data to a message), and make sure to use a pass through transmit pipeline. I'm not sure if this would work with a System.String message or not, but I know it'd work with an XmlDocument message.

e.g.

public static void LoadXLANGMsgFromString(string source, XLANGMessage dest)
{
    var bytes = Encoding.UTF8.GetBytes(source);
    using (MemoryStream ms = new MemoryStream(bytes, 0, bytes.Length, false, true))
    {
        dest[0].LoadFrom(ms);
    }
}

You need to use that constructor of MemoryStream to make sure the base data stream is exposed for XLANGs to make use of. Then, in an Orchestration message assignment shape:

msg = new System.Xml.XmlDocument();
Helper.LoadXLANGMsgFromString("Good plain text format here", msg);



回答2:


Orchestration is expected to work with xml only typed or untyped. With string type, it automatically creates a xml wrapper over it. I think there will not be any way around it, unless you want to use a custom send pipeline component to take out the xml tag before writing.



来源:https://stackoverflow.com/questions/29216428/send-message-of-system-string-is-wrapping-xml

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!