设置最大邮件和缓冲区大小WCF webhttp(Setting Max Message and bu

2019-06-26 22:22发布

我目前有webHttp绑定一个WCF服务,即时通讯试图增加可以通过覆盖在配置的默认设置被输入到该服务的最大尺寸,我试图做这样的事情

  <system.serviceModel>
<bindings>
<webHttpBinding>
  <binding name="webHttp" >
  <security mode="Transport">
      <transport clientCredentialType = 
             "None"
            proxyCredentialType="None"
            realm="string" />
  </security>
  </binding>

</webHttpBinding>
</bindings>
<services>

  <service name="PrimeStreamInfoServices.Service1" behaviorConfiguration="PrimeStreamInfoServices.Service1Behavior">
    <!-- Service Endpoints -->
    <endpoint address="" binding="webHttpBinding"  contract="PrimeStreamInfoServices.IService1">
      <!-- 
          Upon deployment, the following identity element should be removed or replaced to reflect the 
          identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity 
          automatically.
      -->
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="PrimeStreamInfoServices.Service1Behavior">
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
      <serviceMetadata httpGetEnabled="true"/>
      <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<diagnostics>

和设置关于消息的大小不同的其它性质,但没有似乎是工作,可以在一个甚至改变webHttp结合的米essage大小? 有什么建议? 谢谢!

Answer 1:

还有的,可能有一定的影响根据您的设置设置众多 - 试试这个:

<bindings>
  <webHttpBinding>
    <binding name="LargeWeb"
             maxBufferPoolSize="1500000"
             maxReceivedMessageSize="1500000"
             maxBufferSize="1500000">
      <readerQuotas 
            maxArrayLength="656000"
            maxBytesPerRead="656000"
            maxDepth="32"
            maxNameTableCharCount="656000"
            maxStringContentLength="656000"
            />
    </binding>
  </webHttpBinding>
</bindings>

通过定义你的的WebHttpBinding的“版本”,所有这些参数设置为更高的值,你应该能够通过任何邮件大小(几乎)来获得。

提醒你:这样做你的系统开拓的巨大的信息被淹没,从而潜在地降低到其膝盖(拒绝服务经典攻击) - 这是这些限制都设定得相当低的原因 - 通过设计和目的。

你可以将其更改为更高的值 - 只需要知道你在做什么和安全风险是什么,如果你这样做!

PS:为了充分利用这些设置,你当然必须引用您的服务器和客户端CONFIGS绑定配置:

<client>
  <endpoint address="http://localhost"
            binding="webHttpBinding" bindingConfiguration="LargeWeb"
            contract="IMyService" />
</client>
<services>
  <service>
    <endpoint address="http://localhost"
              binding="webHttpBinding" bindingConfiguration="LargeWeb"
              contract="IMyService" />
  </service>
</services>


Answer 2:

设置最大邮件和缓冲区大小WCF REST服务的WebHttpBinding

<bindings>
  <webHttpBinding>
    <binding maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
      <readerQuotas maxDepth="200" maxStringContentLength="83886089" maxArrayLength="163841" maxBytesPerRead="2147483647" maxNameTableCharCount="16384"/>
    </binding>
  </webHttpBinding>
</bindings>


文章来源: Setting Max Message and buffer size for WCF webhttp