【问题标题】:ContractFilter mismatch at the EndpointDispatcherEndpointDispatcher 的 ContractFilter 不匹配
【发布时间】:2012-08-09 16:04:34
【问题描述】:

我有这个错误。我知道问题出在哪里,但我无法解决。 我有正在运行的 WCF Web 服务。 我需要与第一个 Web 服务相同但具有不同名称空间的第二个 Web 服务。 本地主机/test1.svc 本地主机/test2.svc 我不想添加网络引用,所以我在 test1.svc?wsdl 上使用了 wsdl.exe 现在我想用那个类 test2.svc 调用,但我收到了这个错误。
EndpointDispatcher 的 ContractFilter 不匹配 我找到了this

但我不知道如何使用它。或者是否有任何其他方式可以 dinamicli 添加 Web 服务 url。

【问题讨论】:

    标签: c# asp.net wcf


    【解决方案1】:

    使用服务时,您为服务定义两个不同的端点:

    例如

          <endpoint address="address1"
        binding="basicHttpBinding" bindingConfiguration="test1config" contract="service.icontract"
        name="test1endpoint" />
          <endpoint address="address2"
        binding="basicHttpBinding" bindingConfiguration="test2config" contract="service.icontract"
        name="test2endpoint" />
    

    然后您可以像这样指定您希望在代码中使用的端点:

    var channelFactory = new ChannelFactory<IContract>("your-endpoint-name-here");
    

    并使用它以正常方式创建您的频道。

    从中,您可以通过更改端点名称来选择在正确的时间使用哪一个。

    【讨论】:

      猜你喜欢
      • 2013-02-21
      • 2014-04-16
      • 2013-03-09
      • 2011-07-26
      • 1970-01-01
      • 2011-03-28
      • 2018-07-05
      • 2019-07-20
      • 1970-01-01
      相关资源
      最近更新 更多