繁体   English   中英

WCF REST抛出HTTP 400错误maxstringcontentlength配额(8192)

[英]WCF REST throws HTTP 400 error maxstringcontentlength quota (8192) exceeded

基于这篇文章错误使用JSON调用WCF REST服务。 超出长度配额(8192)

从控制台应用程序(使用Microsoft.HttpClient库)调用WCF REST服务(驻留在IIS 7上)时,我遇到了相同的问题。 我在WCF REST服务配置上增加了maxStringContentLength =“ 2147483647”,但对于大于8KB的文件,它仍然会引发相同的错误。 (注意:没有客户端配置,因为我只是发出HTTP Post请求,所以在使用Fiddler进行测试时遇到相同的问题)

这是我的WCF REST配置

<system.serviceModel>
<bindings>
  <webHttpBinding>
    <binding name="webBinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
      <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
    </binding>
  </webHttpBinding>
</bindings>
<services>
  <service behaviorConfiguration="ServiceBehavior" name="EmailService">
    <host>
      <baseAddresses>
        <add baseAddress="http://mywebsite.com/v1" />
      </baseAddresses>
    </host>
    <endpoint address="" binding="webHttpBinding" bindingConfiguration="webBinding" behaviorConfiguration="webBehavior" contract="IEmailService" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="ServiceBehavior">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
  </serviceBehaviors>
  <endpointBehaviors>
    <behavior name="webBehavior">
      <webHttp/>
    </behavior>
  </endpointBehaviors>
</behaviors>

嘿,看来您正在发送更多的数据,然后才允许这样做,即int.max长度,请尝试使用自定义绑定(Binary),它将对您有所帮助

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM