在wcf服务中已超出传入消息的最大邮件大小配额(65536)

时间:2014-08-29 12:41:55

标签: wcf

我正在编写wcf服务以从sql db获取数据。它让我接近大约2000行,有14列。我收到错误'已超出传入邮件的最大邮件大小配额(65536)。要增加配额,请在相应的绑定元素上使用MaxReceivedMessageSize属性。 我的web.config是 -

<system.serviceModel>
<bindings>
  <basicHttpBinding>
    <binding name="BasicHttpBinding_IService1" 
      hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647"
      maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
      transferMode="Buffered">
      <readerQuotas maxDepth="32" maxStringContentLength="2147483647"
        maxArrayLength="2147483647" />
    </binding>
  </basicHttpBinding>
</bindings>
<services>
  <service behaviorConfiguration="serviceBehavior" name="GetSqlData1.Service1">
    <endpoint binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1"
      contract="GetSqlData1.IService1" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="serviceBehavior">
      <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="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>
<protocolMapping>
    <add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>    
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />

1 个答案:

答案 0 :(得分:0)

您好请将此行添加到您的serviceBehaviors部分: -

<dataContractSerializer maxItemsInObjectGraph="2147483646"/>

请参阅下面的示例。

<serviceBehaviors>
        <behavior name="serviceBehavior">
          <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="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"/>
          <!-- Please add this line -->
          <dataContractSerializer maxItemsInObjectGraph="2147483646"/>
        </behavior>
</serviceBehaviors>