0

我有一个 WCF 服务被一个 Windows 服务用这个在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。我怎样才能做到这一点?

4

1 回答 1

3

你需要

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

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

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

http://localhost:24453/AgileService/AgileService

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

于 2011-12-07T16:24:18.017 回答