【问题标题】:Send message of System.String is wrapping xmlSystem.String 的发送消息正在包装 xml
【发布时间】:2015-05-26 19:23:11
【问题描述】:

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

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

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

例如

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

如何防止内容被包装,而不必求助于自定义管道组件?

【问题讨论】:

    标签: biztalk


    【解决方案1】:

    将字符串直接写入帮助程序库中的 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 公开基本数据流以供使用。然后,在 Orchestration 消息分配形状中:

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

    【讨论】:

    • 我必须在上下文中遗漏一些东西 - 在表达式中尝试相同的代码时,我收到错误“无法从 System.Xml.XmlDocument 转换为 Microsoft.XLANGs.Basetypes.XLANGMessage”编辑。可能缺少什么?
    【解决方案2】:

    Orchestration 预计仅适用于输入或未输入的 xml。对于字符串类型,它会自动在其上创建一个 xml 包装器。我想不会有什么办法,除非你想在写之前使用自定义的发送管道组件取出xml标签。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-12-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-06-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多