端点名称匹配

时间:2013-08-28 19:02:03

标签: wcf

我有一个app.config。

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
    <bindings>
        <wsHttpBinding>
          <binding name="WsIGetHeaders" />
        </wsHttpBinding>
      <netTcpBinding>
        <binding name="TcpIGetHeaders" />
      </netTcpBinding>
    </bindings>
    <client>
        <endpoint address="http://localhost:8731/Design_Time_Addresses/DemoService/HeaderService/"
            binding="wsHttpBinding" bindingConfiguration="WsIGetHeaders"
            contract="DemoService.IGetHeaders" name="WsIGetHeaders">
        </endpoint>
      <endpoint address="net.tcp://localhost:8731/Design_Time_Addresses/DemoService/HeaderService/"
          binding="netTcpBinding" bindingConfiguration="TcpIGetHeaders"
          contract="DemoService.IGetHeaders" name="TcpIGetHeaders">
      </endpoint>
    </client>
</system.serviceModel>
</configuration>

我们知道绑定名称必须与bindingConfiguration匹配,但客户端部分中的端点名称如何。我用黑色笔圈了它。红色相互匹配。任何msdn为它? image

1 个答案:

答案 0 :(得分:0)

端点名称在客户端配置中用于在创建客户端实例时在代码中稍后匹配。可以找到一些信息here。 构建服务客户端代理对象的示例,作为从ClientBase派生的每个代理类,其具有适当的ctor

 client = new ServiceClient(useSecure ? "SecureEndpoint" : "defaultEndpoint");