合约需要 Duplex,但绑定“BasicHttpBinding”;不支持它或未正确配置以支持它
我已按照本教程构建我的聊天应用程序。当我尝试添加服务的引用时,出现以下错误:
合同要求双工,但绑定 “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>
I have followed this tutorial for building my chat application. When I try to add reference of my service I get the following error:
Contract requires Duplex, but Binding
'BasicHttpBinding' doesn't support it
or isn't configured properly to
support it.
My web.config is as follows:
<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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当我遇到这个错误时,它让我很痛苦,但解决方案非常简单 - 仔细检查 web.config 中的服务名称。
无论您是否在同一个 Web 程序集中提供服务,您都必须包含服务的完整 TypeName
When I'd got this error, It made a lot of pain for me, but the solution was quite simple - double check service name in your web.config.
wherever you have service in the same web assembly or not, you have to include full TypeName of your service
BasicHttpBinding 是在默认端点上使用的绑定 - 当找不到与服务名称匹配的元素时创建的绑定。元素中的“name”属性必须与服务类的完全限定名称匹配,我猜您的场景并非如此。
如果您使用 C#,完全限定名称将是完整的命名空间 + '.' + 类名。如果您使用的是 VB,则项目的“根命名空间”属性可能会添加到命名空间名称之前。找出要使用的名称的可靠方法是使用反射器或 ildasm 等工具并打开包含服务类的 DLL。
BasicHttpBinding is the binding which is used on the default endpoint - the one which is created when no element can be found which matches the service name. The "name" attribute in the element must match the fully-qualified name of the service class, which I guess isn't the case in your scenario.
If you're using C#, the fully qualified name will be the complete namespace + '.' + the class name. If you're using VB, it's possible that the "root namespace" property of the project is prepended to the namespace name. The sure way to find out the name to use is to use a tool such as reflector or ildasm and open the DLL which contains your service class.