发送包含照片的记录 table 超出限额

Sending records table with photos exceeds quota

代码设置

<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<customBinding>
<binding>
<binaryMessageEncoding />
<httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
</binding>
</customBinding>
<basicHttpBinding>
<binding maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="SilverlightApplication2.Web.EpriscriptionSrv">
<endpoint address="" binding="customBinding"
contract="SilverlightApplication2.Web.EpriscriptionSrv" />
<endpoint address="mex" binding="customBinding" contract="IMetadataExchange" />
</service>
</services>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
</system.serviceModel>

显示错误 帮助

访问但未回复

Wcf-The maximum message size quota for incoming messages (65536) has been exceeded?

您也可以尝试增加自定义绑定的 reader 配额值。

<bindings>
  <customBinding>
    <binding>
      <binaryMessageEncoding>
        <readerQuotas maxDepth="2147483647"
                      maxStringContentLength="2147483647"
                      maxArrayLength="2147483647"
                      maxBytesPerRead="2147483647"
                      maxNameTableCharCounts="2147483647" />
        </readerQuotas>
        <httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
    </binding>
  </customBinding>

此外,您可能希望通过以下行为为 DataContractSerializer 增加 maxItemsInGraph 属性:

<behaviors>
  <serviceBehaviors>
    <behavior>
      <serviceMetadata httpGetEnabled="true" 
                       httpsGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="false" />
      <dataContractSerializer maxItemsInGraph="2147483647" />
    </behavior>
  </serviceBehaviors>
</behaviors>

您的服务主机配置文件与您的客户端应用程序的配置不同。

事实上,增加 maxReceivedMessageSize 在服务器端 web.config 时并没有真正的效果。当您的服务被添加为另一个应用程序中的参考时。它将生成一个客户端配置,就像您在上一个屏幕截图中看到的那样。但是,这通常会默认为较小规模 Web 服务的典型消息大小。

为了接收更大的消息,您必须增加客户端配置的maxReceivedMessageSize属性。

由于您目前正在使用 WCF 测试客户端,因此我将提供几个屏幕截图来说明如何在此处执行此操作:

  1. 启动 WCF 测试客户端时。向下导航到 "Config File",右键单击,然后 select "Edit with SvcConfigEditor"。
  2. 在新的配置编辑器中 window:展开 "Bindings" 菜单和 select 您的绑定。然后编辑 MaxReceivedMessageSize 属性。
  3. 单击文件 -> 保存,然后关闭编辑器。
  4. 在 WCF 测试客户端上。现在应该有一个新的弹出窗口,说明配置已被外部编辑器修改,并提示您重新加载。单击 "Yes" 执行此操作。
  5. WCF 测试客户端中的 "Config File" 菜单现在应该反映新的更改。现在照常在 WCF 测试客户端中进行测试调用。

部署此应用程序时。您必须确保客户端的配置文件在 maxReceivedMessageSize 属性中具有适当的值才能使用您的服务,但这应该暂时获得测试客户端 运行。