我的设置:
- 托管在 IIS Express 中的 ASP.NET 客户端
- 托管在控制台应用程序中的 WCF 服务
- 在管理员模式下运行 Visual Studio.NET 2012
我正在尝试从 WCF 服务返回 2 个 List 对象。当我只返回 1 个 List 对象时,我的设置工作正常。但是当我返回 2 个 List 对象时,我得到了错误:
已超出传入邮件 (65536) 的最大邮件大小配额。要增加配额,请在适当的绑定元素上使用 MaxReceivedMessageSize 属性。
我知道这个问题已经在这个网站和其他网站上被问过很多次了。我已经尝试了几乎所有发布在互联网上的所有配置文件的各种组合,但这对我来说仍然没有成功。
客户端配置:
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpRuntime maxRequestLength="1572864"/>
</system.web>
<system.serviceModel>
<client>
<endpoint name="basicHttpBinding"
address="http://localhost:9502/HCDataService"
binding="basicHttpBinding"
bindingConfiguration="basicHttpBinding"
contract="HC.APP.Common.ServiceContract.IHCServiceContract"
behaviorConfiguration="ServiceBehaviour">
</endpoint>
</client>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBinding" maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="128" maxStringContentLength="2147483647" maxArrayLength="2147483646" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="ServiceBehaviour">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
服务器配置:
<configuration>
<system.serviceModel>
<services>
<service name="HC.APP.Server.Service.HCDataService" behaviorConfiguration="ServiceBehaviour">
<host>
<baseAddresses>
<add baseAddress="http://localhost:9502/HCDataService"/>
</baseAddresses>
</host>
<endpoint name="basicHttpBinding"
address="http://localhost:9502/HCDataService"
binding="basicHttpBinding"
bindingConfiguration="basicHttpBinding"
contract="HC.APP.Common.ServiceContract.IHCServiceContract">
</endpoint>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBinding" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" closeTimeout="01:50:00" openTimeout="01:50:00" sendTimeout="01:50:00" receiveTimeout="01:50:00" >
<readerQuotas maxDepth="128" maxStringContentLength="8388608" maxArrayLength="2147483646" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehaviour">
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceMetadata httpGetEnabled="true" />
<dataContractSerializer ignoreExtensionDataObject="false" maxItemsInObjectGraph="2147483646" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>