wcftestclient - 我可以连接到特定端点吗?

发布于 12-27 00:24 字数 955 浏览 5 评论 0原文

这应该是一个简单的问题。

我无法使用 WCFTestClient 工具连接到特定端点。我有一个服务配置。像这样:

<service name="CO.Services.SvcTest">
        <endpoint address="ep1" binding="basicHttpBinding" bindingConfiguration=""
          bindingNamespace="http://api.CO.com/Services/Tester/ep1"
          contract="CO.Services.ISvcTest" />
        <endpoint address="ep2" binding="basicHttpBinding" bindingConfiguration=""
          bindingNamespace="http://api.CO.com/Services/Tester/ep2"
          contract="CO.Services.ISvcTest_v2" />
        <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
          name="" contract="IMetadataExchange" />
      </service>

如果我通过“http://localhost:2659/Tester.svc/ep1”或“http://localhost:2659/Tester.svc/ep2” ' 我收到“无法从...获取元数据”,但如果我通过 'http://localhost:2659/Tester.svc 它会起作用并显示两个端点。

有谁知道我错过了什么?

EDIT1:这可能吗?

This should be a straightforward question.

I am unable to connect to a specific endpoint using WCFTestClient tool. I have a service config. like this:

<service name="CO.Services.SvcTest">
        <endpoint address="ep1" binding="basicHttpBinding" bindingConfiguration=""
          bindingNamespace="http://api.CO.com/Services/Tester/ep1"
          contract="CO.Services.ISvcTest" />
        <endpoint address="ep2" binding="basicHttpBinding" bindingConfiguration=""
          bindingNamespace="http://api.CO.com/Services/Tester/ep2"
          contract="CO.Services.ISvcTest_v2" />
        <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
          name="" contract="IMetadataExchange" />
      </service>

If I pass 'http://localhost:2659/Tester.svc/ep1' or 'http://localhost:2659/Tester.svc/ep2' I get "Cannot obtain Metadata from..." but if I pass 'http://localhost:2659/Tester.svc it works and shows me both endpoints.

Does anyone know what am I missing?

EDIT1: Is this even possible?

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

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

发布评论

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

评论(1

怀里藏娇2025-01-03 00:24:06

这是正确的行为

在 WCF 中,默认情况下,服务的元数据在服务的基地址处提供。

如果您在自定义进程中托管服务,则可以自定义基本地址的 URL,甚至可以使用 baseAddresses 配置部分。如果您在 IIS 中托管服务(您的情况似乎如此),则基地址始终是 .svc 文件的 URL。

编辑:
如果您想要两个完全独立的端点,那么您必须创建两个服务实现,每个合约一个,并在配置文件中使用不同的元素配置它们。只要端点是同一服务的一部分,您就只能从服务的基地址检索元数据,在您的情况下,基地址是 .svc 文件的 URL。

That's the correct behavior.

In WCF a service's metadata is served at the service's base address by default.

If you're hosting your service in a custom process, you can customize the URL of the base address or even add new ones using the baseAddresses configuration section. If you're hosting the service in IIS, which seems to be your case, then the base address is always the URL of the .svc file.

EDIT:
If you want two completely separate endpoints, then you will have to create two service implementations, one for each contract, and configure them with different elements in your configuration file. As long as the endpoints are part of the same service, you will only be able to retrieve the metadata from the service's base address, which in your case is the URL of the .svc file.

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