如何添加具有固定端口的 WCF 服务引用?

发布于 2024-12-20 07:13:54 字数 805 浏览 4 评论 0原文

我有一个由 Windows 服务托管的 WCF 服务,该服务位于 app.config

  <services>
    <service behaviorConfiguration="serviceBehavior" name="AgileServer.AgileService">
      <endpoint address="AgileService" binding="basicHttpBinding" name="basicHttp" contract="AgileServer.AgileService" />
      <endpoint binding="mexHttpBinding" name="mex" contract="IMetadataExchange" />
      <host>
        <baseAddresses>
          <add baseAddress="http://localhost:24453/AgileService" />
        </baseAddresses>
      </host>
    </service>

当我尝试向我的服务添加服务引用时(通过单击“添加服务引用”提示中的“发现”), ),URI 显示为 http://localhost:33908/AgileService.svc 我希望我的服务使用 http://localhost:24453/AgileService 作为 URI 。我怎样才能做到这一点?

I have a WCF service being hosed by a Windows Service with this in the app.config

  <services>
    <service behaviorConfiguration="serviceBehavior" name="AgileServer.AgileService">
      <endpoint address="AgileService" binding="basicHttpBinding" name="basicHttp" contract="AgileServer.AgileService" />
      <endpoint binding="mexHttpBinding" name="mex" contract="IMetadataExchange" />
      <host>
        <baseAddresses>
          <add baseAddress="http://localhost:24453/AgileService" />
        </baseAddresses>
      </host>
    </service>

When I try to add a service reference to my service (by clicking "Discover" in the "Add Service Reference" prompt), the URI shows up as http://localhost:33908/AgileService.svc I want my service to use http://localhost:24453/AgileService as the URI. How can I accomplish this?

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

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

发布评论

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

评论(1

私藏温柔 2024-12-27 07:13:54

您需要

  • 在 Windows 服务中启动并运行 WCF 服务,
  • 不要单击“发现”,而是输入/粘贴您要连接到的 URL - 要么使用基地址 (>http://localhost:24453/AgileService)或 MEX 端点的地址 (http://localhost:24453/AgileService/mex)

这样做将连接到定义的 URL,并且服务元数据将是检索并用于为服务创建客户端代理。

顺便说一句:您的实际服务 URL 将是:

http://localhost:24453/AgileService/AgileService

由您的基地址 (http://localhost:24453/AgileService) 加上< /em> 端点上的相对地址 (AgileService)。

You need to

  • have the WCF service in your Windows service up and running
  • do not click on Discover, but instead type in / paste in the URL you want to connect to - either use the base address (http://localhost:24453/AgileService) or the MEX endpoint's address (http://localhost:24453/AgileService/mex)

Doing this will connect to the URL defined, and the service metadata will be retrieved and used to create a client-side proxy for the service.

Just as a side-note: your actual service URL will be:

http://localhost:24453/AgileService/AgileService

made up of your base address (http://localhost:24453/AgileService) plus the relative address on the endpoint (AgileService).

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