.NET Framework 4 中的 Web 服务的 Web 方法是否可以有多个名称或别名?

发布于 2025-01-14 22:12:52 字数 229 浏览 3 评论 0原文

目前,我正在努力更改 Web 服务中某些 Web 方法的名称。

[WebMethod(MessageName ="HelloWorld2",MessageName = "HelloWorld")]
public string HelloWorld()
{
    return "Hello World";
}

我想知道:同一个方法是否可以有不同的消息名称?或者有相同结果的东西?

Currently, I'm working on changing the name of some web methods in a web service.

[WebMethod(MessageName ="HelloWorld2",MessageName = "HelloWorld")]
public string HelloWorld()
{
    return "Hello World";
}

I wonder: is it possible to have different message names for the same method? Or something with the same result?

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

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

发布评论

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

评论(1

热风软妹 2025-01-21 22:12:52

我的第一个方法是从旧方法调用新的实现。我对想法持开放态度

[WebMethod]
    public string HelloWorld2(string s)
    {
        return $"Hello {s}";
    }

    [WebMethod]
    public string HelloWorld3(string s)
    {
        return HelloWorld2(s);
    }

My first approach is calling the new implementation from the old method. I'm open to ideas

[WebMethod]
    public string HelloWorld2(string s)
    {
        return 
quot;Hello {s}";
    }

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