未正确读取绑定配置

发布于 2024-09-16 14:23:51 字数 2119 浏览 4 评论 0原文

我有一个返回大量数据的 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 访问我的 webSerice 时(该服务托管在 VS 或 IIS 中),我检查配置并

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>

我知道绑定配置可以工作,因为我能够通过 WCFTestClient 测试传输安全性。任何见解将不胜感激。

谢谢!

I have a WCF service that returns a lot of data. So much so that I needed to increase the maxBufferSize and the maxReceivedMessageSize. My endpoint and binding look like so:

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

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

As far as I can tell the above is configured correctly. When I access my webSerice through the WCFTestClient (with the service either being hosting in VS or IIS) I check the config and

1) The client section does not have the name of my bindingConfiguration in it

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

2) The binding that gets sucked into the client does not have an updated maxZBufferSize or maxReceivedMessageSize, and transport and message security stubs are being pulled over somehow.

<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>

I know that bindingConfiguration works as I was able to test transport security through the WCFTestClient. Any insight would be appreciated.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

寄意 2024-09-23 14:23:51

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

IOW,您将必须手动调整您的客户端配置。

As far as I remember, that detail of binding parameters are not publicly exposed in the published metadata. The only reason why the service proxies generated using VS/Svcutil contain all that is because, well, they are very dumb and serialize the binding configurations with all the values, even though all of them contain the standard default values!

IOW, you're going to have to manually tweak your client configuration.

缘字诀 2024-09-23 14:23:51

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

Not all binding parameters are transfered. Morover message size configuration is defense against denial of service attack so each service and client can have its own configuration and it will be bad if this configuration is overwritten each time you regenerate proxy. It is called maxReceiveMessageSize so it only checks the size of incomming messages. You have to set this parameter to expected size of message on receiving side. For example if you only plan to download large dataset from the service you don't need to configure high value on that service side because it will not receive this dataset it will send it. On the client side you have to set this parameter otherwise message will not be processed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文