【问题标题】:WCF customBinding problemWCF 自定义绑定问题
【发布时间】:2011-09-27 22:24:33
【问题描述】:

我一直在玩 pollingDuplex 示例,这让我发疯了。我正在使用 customBinding 来集成 readerQuotas 元素,但我不断收到错误消息:“合同需要 Duplex,但绑定 'BasicHttpBinding' 不支持它或未正确配置以支持它。” 当我使用 customBinding 时,BasicHttpBinding 来自哪里?我检查了无数示例,我的配置文件与他们所拥有的匹配,但它不起作用。谁能帮我这个 ? 谢谢。

<configuration>
<system.serviceModel>

<extensions>
  <bindingElementExtensions>
    <add name="pollingDuplex" type="System.ServiceModel.Configuration.PollingDuplexElement, System.ServiceModel.PollingDuplex"/>
  </bindingElementExtensions>
</extensions>

<bindings>
  <customBinding>
    <binding name="DBNotification" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00">
      <httpsTransport maxBufferSize="2147483647" maxBufferPoolSize="2147483647"
         maxReceivedMessageSize="2147483647"/>
      <pollingDuplex duplexMode="MultipleMessagesPerPoll" maxPendingSessions="2147483647" maxPendingMessagesPerSession="2147483647"/>
      <binaryMessageEncoding>
        <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
            maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
      </binaryMessageEncoding>
    </binding>
  </customBinding>
</bindings>

<services>
  <service name="AdminWebService" behaviorConfiguration="DBNotificationServiceBehavior">
    <endpoint address="adminservice" binding="customBinding" bindingConfiguration="DBNotification" contract="AdminWebService.IAdminWebService" />
    <endpoint address="mex"
          binding="mexHttpBinding"
          contract="IMetadataExchange"/>
  </service>
</services>

<behaviors>
        <serviceBehaviors>      
    <behavior name="DBNotificationServiceBehavior">
      <serviceMetadata httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="true"/>
      <serviceThrottling maxConcurrentSessions="2147483647"/>
    </behavior>
  </serviceBehaviors>
    </behaviors>
</system.serviceModel>

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>

【问题讨论】:

  • 我不知道是不是这种情况,但是您可以尝试在自定义绑定中更改元素的顺序,以便传输是最后一个(即&lt;pollingDuplex/&gt;、@987654323 @ 然后&lt;httpsTransport/&gt;)?当您使用代码创建自定义绑定时,IIRC 会强制执行此顺序。
  • 不,同样的事情。就好像它在某个地方检查另一个宇宙中的另一个 web.config 文件。

标签: wcf


【解决方案1】:

您可能遇到了“简化配置”问题 - 在http://blogs.msdn.com/b/endpoint/archive/2009/11/09/common-user-mistake-in-net-4-mistyping-the-service-configuration-name.aspx 中有详细描述。 &lt;service&gt; 元素中的“名称”属性必须是服务的完全限定名称。既然你的接口是AdminWebService.IAdminWebService,那你的服务名不是AdminWebService.AdminWebService吗?如果是这样,修复 name 属性应该可以解决问题。

【讨论】:

  • 该死的就是这样。我实际上阅读了该问题,但没有在我的配置中发现它。误导我的是,当我使用简单的 [ServiceContract] 时,相同的配置工作得很好,但是一旦我将它变成 [ServiceContract(CallbackContract = typeof(IDuplexClient))] 来实现客户端回调,就会弹出错误。非常感谢 !我正在逼自己发疯,试图弄清楚这一点。
【解决方案2】:

httpGetEnabled="true" 是否可能暗示使用BasicHttpBinding?你真的需要这个功能吗?如果您评论此行,错误会消失吗?

【讨论】:

  • 我也想过。尝试将其注释掉并将其设置为 false。一样。仍然以某种方式转换为 BasicHttpBinding。
  • @algorunescu:那你能提供你的自定义绑定实现吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-02-07
  • 2011-12-22
  • 1970-01-01
  • 1970-01-01
  • 2011-06-05
  • 2010-11-29
  • 2019-11-21
相关资源
最近更新 更多