gpt4 book ai didi

c# - WCF 错误 - 已超过传入消息 (65536) 的最大消息大小配额

转载 作者:IT王子 更新时间:2023-10-29 04:33:54 28 4
gpt4 key购买 nike

<分区>

我的设置:

  • 在 IIS Express 中托管的 ASP.NET 客户端
  • 在控制台应用程序中托管的 WCF 服务
  • 在管理员模式下运行 Visual Studio.NET 2012

我正在尝试从 WCF 服务返回 2 个列表对象。当我只返回 1 个列表对象时,我的设置工作正常。但是当我返回 2 个 List 对象时,我得到了错误:

已超过传入消息的最大消息大小配额 (65536)。要增加配额,请在适当的绑定(bind)元素上使用 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>

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com