我可以在调用端点之前了解端点支持哪些 WCF 方法吗?

发布于 2024-09-02 05:03:53 字数 354 浏览 4 评论 0原文

我遇到 WCF 服务合约的版本控制问题,其中为操作调用的众多端点之一缺少合约中的一种方法。

我的问题是,在尝试调用该命令之前,如何确保该命令在客户端上可用?

我尝试过:

  foreach (var od in proxy.Endpoint.Contract.Operations)
  {
    if (od.Name == "MyMethodName")
    {
      hasMethod = true;
      break;
    }
  }

不幸的是,这是使用调用应用程序的合同,并且实际上并没有描述端点本身的实现。因此,即使端点未能执行该命令,它也会返回 true。

I have a versioning issue with a WCF service contract in which one of the many endpoints which are called for the operation is missing one method from the contract.

My question is, how can I make sure the command is available on the client before attempting to call it?

I tried:

  foreach (var od in proxy.Endpoint.Contract.Operations)
  {
    if (od.Name == "MyMethodName")
    {
      hasMethod = true;
      break;
    }
  }

Unfortunately, this is using the contract from the calling app and does not actually describe the implementations on the endpoint itself. As a result, it returns true even though the endpoint has failed to implement the command.

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

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

发布评论

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

评论(1

忆沫 2024-09-09 05:03:53

在你尝试之前你永远不会真正知道。您拥有的是已实施合约的代理,但服务器端的内容可能会在您创建/生成它后发生变化。

假设它是一个 http/httpws 实现,我想您可以调用并检查服务引用并下载 wsdl 文件。这将告诉您支持哪些方法等。您将遇到的问题是,即使方法的名称可能相同,您也必须检查返回类型和参数,以真正确保它是相同的方法并且您可以使用您当前拥有的代理。

以下是有关 WCF 版本控制的链接:
http://msdn.microsoft.com/en-us/library/ms731060。 aspx

以下是有关 WCF 版本控制最佳实践的链接:
使用 WCF 对服务进行版本控制的最佳实践?

You'll never actually know until you try it. What you have is a proxy of the implemented contract, but what is on the server side could have changed since you created/generated it.

Assuming it's an http/httpws implementation I suppose you could call and check the service reference and download the wsdl file. That will tell you what methods etc are supported. The problem you're going to have is that even though the name of the method maybe the same, you'll also have to check the return type and parameters to really be sure that it's the same method and that you can call it with the proxy you currently have.

Here is a link on versioning in WCF:
http://msdn.microsoft.com/en-us/library/ms731060.aspx

Here is a link on versioning best practices for WCF:
Best practices for versioning your services with WCF?

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