如何根据Request.InputStream判断调用了哪个WS方法?

发布于 2024-12-27 14:39:04 字数 182 浏览 5 评论 0原文

在 HttpModule 中,我想弄清楚哪个 Web 方法被调用/拦截,并据此采取行动。例如,如果我调用 WebMethod1,则执行某些操作,但对 WebMethod2 不执行任何操作。

如果我查看soap:Header 和soap:Body,我可以看到方法名称,但是解析soap:Envelope 可以吗?如果可以,解析哪一部分?

Within a HttpModule, I'd like to figure out which web method was called/intercepted and act based on that. For example, if I called WebMethod1, do something, yet do nothing for WebMethod2.

If I look at soap:Header and soap:Body, I can see the method name but would it be alright to parse the soap:Envelope and if so, which part?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

甜味拾荒者 2025-01-03 14:39:04

如果这两个方法有一个公共端点,您需要解析 SOAP 消息以确定调用哪个方法。在这种情况下,您需要检查 标记并找到属于 body 标记的第一个元素名称的操作名称。

If the two method have a common endpoint you need to parse the SOAP message to determine what method is called. In this case you need to check the <soap:Body> tag and find the operation name that is the first element name that belongs to the body tag.

清醇 2025-01-03 14:39:04

这是我解析肥皂消息的代码:

    System.Xml.XmlDocument doc=new System.Xml.XmlDocument();
    doc.LoadXml(soapMessage);

    foreach (XmlNode xn in doc)
    {
        foreach (XmlElement element in xn)
        {
            if (element.Name == "soap:Body")
                result = element.FirstChild.Name;
        }
    }

    return result;

Here's my code that parses the soap message:

    System.Xml.XmlDocument doc=new System.Xml.XmlDocument();
    doc.LoadXml(soapMessage);

    foreach (XmlNode xn in doc)
    {
        foreach (XmlElement element in xn)
        {
            if (element.Name == "soap:Body")
                result = element.FirstChild.Name;
        }
    }

    return result;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文