【问题标题】:WCF proxy creation at client side with multiple endpoint在具有多个端点的客户端创建 WCF 代理
【发布时间】:2013-01-15 07:51:05
【问题描述】:

我有一个带有两个端点的服务。一个端点用于 wsdual 绑定,另一个用于 tcp 绑定。当我使用 wcfsvchost.exe

启动我的 wcf 服务时
WcfSvcHost.exe /service:"C:
\Users\TRIDIP\Documents\Visual Studio 2010\Projects\BBAChatService\BBAChatService\bin
\BBAChatService.dll" /config:"C:\Users\TRIDIP\documents\visual studio 2010\Projects
\BBAChatService\BBAChatService\Web.config"

然后我的服务就启动了。

问题是,当我尝试在使用 WcfSvcHost.exe 启动服务后在客户端创建代理时,所有与端点相关的信息都会添加到客户端的配置文件中,但我希望当我将使用 tcp mex 端点或来自客户端的 mexHttpBinding 创建代理时那么只有有效的端点应该添加到客户端的配置文件中,而不是所有端点。所以请指导我在服务端在我的配置文件中进行哪些更改。这是我在服务端的配置文件....请看一下。

<service name="BBAChatService.ChatService" behaviorConfiguration="BBAChatService.ChatServiceBehavior" >
        <host>
          <baseAddresses>
            <add baseAddress ="http://localhost:8732/ChatService.svc/"/>
            <add baseAddress ="net.tcp://localhost:7998/ChatService/"/>
          </baseAddresses>
        </host>

        <endpoint name="dual_bind"
                  address="dual"
                  binding="wsDualHttpBinding" 
                  bindingConfiguration="WSDualHttpBinding_IChatService" 
                  contract="BBAChatService.IChatService">
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>

        <endpoint name="tcp_bind"
              address="tcp"
              binding="netTcpBinding"
              bindingConfiguration="tcpBinding"
              contract="BBAChatService.IChatService">
        </endpoint>

        <endpoint address="net.tcp://localhost:7996/ChatService/mex"
                          binding="mexTcpBinding"
                          contract="IMetadataExchange"/>


      </service>

指导我在我的配置中进行哪些更改。谢谢

【问题讨论】:

  • 我不确定这是否可行。在这里隐藏一个端点时,确实需要它们的客户端无法再生成代理类。您无法控制消费者使用的“工具”。

标签: wcf


【解决方案1】:

如果您在同一个服务中公开多个端点,则您在 WSDL 中有多个端口,并且 svcutil(添加服务引用)将为每个提供的端口导入配置。 WSDL 始终公开所有已定义的服务端点,并且 svcutil 与所有端点一起工作。

您必须手动修改客户端配置以删除客户端的 HTTP 端点配置,或者必须将服务拆分为两个不同的实现,每个实现都有一个端点。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多