【问题标题】:Extracting userid from Inbound headers从入站标头中提取用户 ID
【发布时间】:2013-03-04 14:39:01
【问题描述】:

我必须从 Inbound Header 中读取元素...

我正在使用 WCF.InboundHeaders 将入站标头分配给字符串....

现在我的问题是我的 inbounde 标头看起来像这样

InboundHeaders

<headers><s:userid xmlns:s="http://www.w3.org/2003/05/soap-envelope">testuser</s:userid>

 <s:applicationid xmlns:s="http://www.w3.org/2003/05/soap-envelope">assistworkerweb</s:applicationid>

<a:Action s:mustUnderstand="1" xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">http://Request</a:Action><a:To s:mustUnderstand="1" xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">

现在我需要从中提取用户 ID ..如何从中提取用户 ID ..

【问题讨论】:

  • 你没有对你的设置给出足够的解释来理解你在做什么。

标签: biztalk biztalk-2010 biztalk-2009 biztalk2006r2


【解决方案1】:

您没有提到您的字符串的存储位置或方式(使用 WCF.InboundHeaders 填充),但是我将使用 XPath 的一个简单片段来提取 UserId。如果您使用 C# 帮助程序来提取它,您可以按照以下方式执行一些操作(注意,这是未经测试的,但它几乎在那里):

XmlDocument doc = new XmlDocument();
doc.Load([WCF.InboundHeaders Xml Fragment]);

// Create an XmlNamespaceManager to add 'soap-envelope' namespace
XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);
nsmgr.AddNamespace("s", "http://www.w3.org/2003/05/soap-envelope");

// Select the UserId
XmlNode userId = doc.SelectSingleNode("/headers/s:userid", nsmgr);
Console.WriteLine(userId.InnerXml);

您可能还希望将 Xml 片段序列化为 .Net 对象并以这种方式检索 UserId。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-10-31
    • 2023-04-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-29
    • 1970-01-01
    相关资源
    最近更新 更多