2009-07-27 77 views
5

我目前有一个WCF服务与WebHttp绑定,即时通过覆盖配置中的默认设置,试图增加可以输入到服务的最大大小,我试着做类似为WCF设置最大消息和缓冲区大小webhttp

<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大小? 有什么建议吗?谢谢!

+0

你能发布你的配置文件的相关部分吗? – 2009-07-27 15:19:05

+0

刚刚编辑,检查出 – Daniel 2009-07-27 16:55:20

回答

12

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

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

设置最大邮件和缓冲区大小for WCF Rest服务webhttpbinding

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