System.String的发送消息正在包装xml



我有一个简单的odx,它构造一个System.String类型的消息,然后通过发送端口推出。

输出消息的内容很好,只是前缀为:

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

例如

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

如何在不必使用自定义管道组件的情况下防止内容被包装?

将字符串直接写入助手库中的XLANGMessage(就像将二进制数据写入消息一样),并确保使用直通传输管道。我不确定这是否适用于System.String消息,但我知道它适用于XmlDocument消息。

例如

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);
    }
}

您需要使用MemoryStream的构造函数来确保基本数据流公开给XLANG使用。然后,在编排消息分配形状中:

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

Orchestration应仅使用类型化或非类型化的xml。对于字符串类型,它会自动在上面创建一个xml包装器。我认为不会有任何方法绕过它,除非你想在编写之前使用自定义的发送管道组件来取出xml标记。

最新更新