【问题标题】:Contract requires Duplex, but Binding 'BasicHttpBinding' doesn't support it or isn't configured properly to support it合同需要 Duplex,但绑定“BasicHttpBinding”不支持它或未正确配置以支持它
【发布时间】:2011-08-25 21:16:12
【问题描述】:

我已按照本教程构建我的聊天应用程序。当我尝试添加对我的服务的引用时,我收到以下错误:

Contract 需要 Duplex,但 Binding 'BasicHttpBinding' 不支持 或未正确配置为 支持一下。

我的web.config如下:

<extensions>
  <bindingExtensions>
    <add name="pollingDuplex" type="System.ServiceModel.Configuration.PollingDuplexHttpBindingCollectionElement,System.ServiceModel.PollingDuplex, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
  </bindingExtensions>
</extensions>

<bindings>      
  <pollingDuplex>
    <binding name="chatPollingDuplex" duplexMode="MultipleMessagesPerPoll"/>
  </pollingDuplex>
</bindings>    

<services>      
  <service name="PrototypeSite.ChatService">        
    <endpoint address="" binding="pollingDuplex" bindingConfiguration="chatPollingDuplex" contract="PrototypeSite.ChatService" />
    <endpoint address="mex" binding="wsDualHttpBinding" contract="IMetadataExchange"/>
  </service>      
</services>

【问题讨论】:

  • 我将从更正mex 端点开始。您使用的绑定不正确。
  • 谢谢...那该用什么??
  • Mex 端点与mexHttpBinding 一起使用
  • 我已将 mex 端点更改为: 但问题仍然存在。

标签: silverlight wcf ria wcf-ria-services duplex


【解决方案1】:

当我遇到这个错误时,这让我很痛苦,但解决方案非常简单 - 仔细检查 web.config 中的服务名称。

无论您是否在同一个 Web 程序集中提供服务,您都必须包含服务的完整类型名称

【讨论】:

    【解决方案2】:

    BasicHttpBinding 是在默认端点上使用的绑定 - 当找不到与服务名称匹配的元素时创建的绑定。元素中的“name”属性必须与服务类的完全限定名称匹配,我猜你的场景不是这种情况。

    如果您使用 C#,则完全限定名称将是完整的命名空间 + '.' + 班级名称。如果您使用的是 VB,则项目的“根命名空间”属性可能会附加到命名空间名称之前。确定要使用的名称的可靠方法是使用反射器或 ildasm 等工具并打开包含您的服务类的 DLL。

    【讨论】:

    • 感谢您的回复! name 属性的命名空间部分不正确。它是 Prototype.ChatService 而不是 PrototypeSite.ChatService。但问题仍然存在:(
    • +1 BasicHttpBinding 是在默认端点上使用的绑定
    猜你喜欢
    • 2012-12-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多