简体   繁体   English

获取错误:合同需要Duplex,但Binding'BasicHttpBinding'不支持它,或者没有正确配置以支持它

[英]Getting an error: Contract requires Duplex, but Binding 'BasicHttpBinding' doesn't support it or isn't configured properly to support it

I have a WCF service and a Silverlight 5 client. 我有一个WCF服务和一个Silverlight 5客户端。 I've defined the following interfaces: 我已经定义了以下接口:

[ServiceContract(Namespace = "Silverlight", CallbackContract = typeof(IDuplexClient))]
public interface IDuplexService
{
    [OperationContract]
    void Subscribe(string userId);

    [OperationContract]
    void Unsubscribe(string userId);
}

[ServiceContract]
public interface IDuplexClient
{
    [OperationContract(IsOneWay = true)]
    void PushNotification(string msg);
}

And this is my Web.config file: 这是我的Web.config文件:

<configuration>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
</configuration>

When I try to run the service I get: 当我尝试运行服务时,我得到:

The service '/ServerService.svc' cannot be activated due to an exception during compilation. 由于编译期间发生异常,无法激活服务'/ServerService.svc'。 The exception message is: Contract requires Duplex, but Binding 'BasicHttpBinding' doesn't support it or isn't configured properly to support it. 异常消息是:Contract需要Duplex,但Binding'BasicHttpBinding'不支持它,或者没有正确配置以支持它。

I know I need to add some properties to Web.config, but wherever I looked (and whatever I tried) I couldn't make it work. 我知道我需要为Web.config添加一些属性,但无论我在哪里(以及我尝试过的任何东西)都无法使其工作。

I'm new to WCF and I'd like your help on that subject. 我是WCF的新手,我希望你对这个问题有所帮助。 All my googling lead me nowhere and the answers people who asked here the same question got doesn't work for me. 我所有的谷歌搜索引导我无处可回答在这里问同样问题的人的答案对我不起作用。

So I've decided to give up searching and just ask. 所以我决定放弃搜索,然后问。

Update: I used this link to create the interface - http://msdn.microsoft.com/en-us/library/cc645027%28v=vs.95%29.aspx 更新:我使用此链接创建界面 - http://msdn.microsoft.com/en-us/library/cc645027%28v=vs.95%29.aspx

If that is the extent of your web.config configuration for WCF, then you are missing the 如果这是WCF的web.config配置的范围,那么你就错过了 section that defines your contract: 定义合同的部分:

<services>
  <service name="WebApplication1.Service1">
    <endpoint address="" binding="wsDualHttpBinding" contract="WebApplication1.IService1" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>
</services>

If you do have this section specified, the other likely cause is that the contract name is not fully qualified; 如果您确实指定了此部分,另一个可能的原因是合同名称不是完全合格的; it must include the full namespace and not just the name of the contract. 它必须包含完整的命名空间,而不仅仅是合同的名称。

Here is the full System.ServiceModel configuration: 以下是完整的System.ServiceModel配置:

  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
    <services>
      <service name="WebApplication1.Service1">
        <endpoint address="" binding="wsHttpBinding" contract="WebApplication1.IService1" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
  </system.serviceModel>

In this case, the application namespace is WebApplication1, the service's class name is Service1 (ie Service1.svc) and the interface that Service1 implements is IService1. 在这种情况下,应用程序命名空间是WebApplication1,服务的类名是Service1(即Service1.svc),Service1实现的接口是IService1。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法添加服务器引用:合同需要双工,但绑定“BasicHttpBinding”不支持或未正确配置以支持它 - Cannot add server reference: Contract requires Duplex, but Binding 'BasicHttpBinding' doesn't support it or isn't configured properly to support it 收到错误消息“此页面使用框架,但您的浏览器不支持” - Getting error “This page uses frames, but your browser doesn't support” 如何刷新绑定到不支持 INotyfyPropertyChanged 的属性? - How to refresh binding to property that doesn't support INotyfyPropertyChanged? 尝试获取DicomDataset时获取“ DicomTag不支持值” - Getting “DicomTag doesn't support values” when trying to obtain DicomDataset Microsoft JScript运行时错误:对象不支持此属性或方法 - Microsoft JScript runtime error: Object doesn't support this property or method 运行时错误438。对象不支持此属性或方法 - Runtime error 438. Object doesn't support this property or method 远程调试 - 远程调试器不支持此版本的Windows错误 - Remote debugging - Remote debugger doesn't support this version of Windows error Microsoft JScript运行时错误:对象不支持此属性或方法 - Microsoft JScript runtime error: Object doesn't support this property or method basicHttpBinding不使用自定义ServiceCredentials - basicHttpBinding doesn't use custom ServiceCredentials VBA和“类不支持自动化或不支持预期的接口” - VBA and “Class doesn't support Automation or does not support expected interface”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM