【问题标题】:bindingConfiguration not being read properlybindingConfiguration 没有被正确读取
【发布时间】:2011-04-07 02:06:18
【问题描述】:

我有一个返回大量数据的 WCF 服务。以至于我需要增加 maxBufferSize 和 maxReceivedMessageSize。我的端点和绑定如下所示:

<endpoint 
    address=""
    binding="basicHttpBinding"
    bindingConfiguration="ExtendedBinding"
    contract="NAThriveExtensions.INableAPI"
/>

<bindings>
  <basicHttpBinding>
    <binding
       name="ExtendedBinding"
       maxBufferSize="655360"
       maxReceivedMessageSize="655360" >
    </binding>
  </basicHttpBinding>
</bindings>

据我所知,以上配置正确。当我通过 WCFTestClient(服务托管在 VS 或 IIS 中)访问我的 webSerice 时,我会检查配置并

1) 客户端部分没有我的 bindingConfiguration 的名称

<client>
    <endpoint
       address="http://wikittybam/NAThriveExtensions/NableAPI.svc"
       binding="basicHttpBinding" 
       bindingConfiguration="BasicHttpBinding_INableAPI"
       contract="INableAPI" name="BasicHttpBinding_INableAPI" />
</client>

2) 被吸入客户端的绑定没有更新的 maxZBufferSize 或 maxReceivedMessageSize,并且传输和消息安全存根以某种方式被拉回。

<bindings>
  <basicHttpBinding>
    <binding name="BasicHttpBinding_INableAPI" closeTimeout="00:01:00"
       openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
       allowCookies="false" bypassProxyOnLocal="false"      
       hostNameComparisonMode="StrongWildcard"
       maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
       messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
       useDefaultWebProxy="true">
       <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
         maxBytesPerRead="4096" maxNameTableCharCount="16384" />
         <security mode="None">
           <transport clientCredentialType="None" proxyCredentialType="None"
                        realm="" />
           <message clientCredentialType="UserName" algorithmSuite="Default" />
         </security>
    </binding>
  </basicHttpBinding>
</bindings>

我知道 bindingConfiguration 有效,因为我能够通过 WCFTestClient 测试传输安全性。任何见解将不胜感激。

谢谢!

【问题讨论】:

    标签: wcf binding web-config wcf-binding


    【解决方案1】:

    据我所知,绑定参数的详细信息并未在已发布的元数据中公开。使用 VS/Svcutil 生成的服务代理包含所有这些的唯一原因是,它们非常愚蠢,并且使用所有值序列化绑定配置,即使它们都包含标准默认值!

    IOW,您将不得不手动调整您的客户端配置。

    【讨论】:

    • 谢谢。使用我的 WCF 服务的应用程序不是基于 .Net 的,当我在该应用程序中使用该服务时一切正常。从测试的角度来看很糟糕,但很高兴它有效。
    【解决方案2】:

    并非所有绑定参数都被传输。 Morover 消息大小配置是针对拒绝服务攻击的防御,因此每个服务和客户端都可以有自己的配置,如果每次重新生成代理时都覆盖此配置会很糟糕。它被称为 maxReceiveMessageSize,因此它只检查 incomming 消息的大小。您必须将此参数设置为 接收 端的预期消息大小。例如,如果您只打算从服务中下载大型数据集,则不需要在该服务端配置高值,因为它不会收到此数据集,而是会发送它。在客户端,您必须设置此参数,否则将不会处理消息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-01-06
      • 2019-06-04
      • 1970-01-01
      • 2014-06-25
      • 2023-02-13
      • 1970-01-01
      • 2013-02-28
      • 1970-01-01
      相关资源
      最近更新 更多