C# 有关MaxReceivedMessageSize的WCF错误

C# 有关MaxReceivedMessageSize的WCF错误,c#,wcf,C#,Wcf,我研究这个错误已经有一段时间了,我觉得这个问题一直被问到……但我似乎找不到问题所在 我收到正常的MaxReceivedMessageSize错误: The maximum message size quota for incoming messages (65536) has been exceeded. 我的服务配置中是否缺少某些内容 <system.serviceModel> <services> <service name="LifeEApplicat

我研究这个错误已经有一段时间了,我觉得这个问题一直被问到……但我似乎找不到问题所在

我收到正常的
MaxReceivedMessageSize
错误:

The maximum message size quota for incoming messages (65536) has been exceeded. 
我的服务配置中是否缺少某些内容

<system.serviceModel>
<services>
  <service name="LifeEApplication.Services.RateService.RateServiceHost" behaviorConfiguration="RateService.RateServiceHostBehavior">
    <endpoint address="" binding="basicHttpBinding" contract="LifeEApplication.Services.Contracts.RateServiceContract.IRateService"/>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="RateService.RateServiceHostBehavior">
      <serviceMetadata httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="true"/>
      <serviceThrottling maxConcurrentCalls="200" maxConcurrentSessions="200" maxConcurrentInstances="200"/>
      <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<bindings>
  <basicHttpBinding>
    <binding name="BasicBinding" 
             maxBufferPoolSize="2147483647" 
             maxBufferSize="2147483647" 
             maxReceivedMessageSize="2147483647" 
             receiveTimeout="00:02:00" 
             sendTimeout="00:02:00">

      <readerQuotas maxDepth="2147483647" 
                    maxStringContentLength="2147483647" 
                    maxArrayLength="2147483647" 
                    maxBytesPerRead="2147483647" 
                    maxNameTableCharCount="2147483647"/>

      <security mode="Transport">
        <transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
        <message clientCredentialType="Certificate" algorithmSuite="Default"/>
      </security>
    </binding>
    <binding name="LocalBinding" 
             maxBufferPoolSize="2147483647" 
             maxBufferSize="2147483647" 
             maxReceivedMessageSize="2147483647" 
             receiveTimeout="00:02:00" 
             sendTimeout="00:02:00">

      <readerQuotas maxDepth="2147483647" 
                    maxStringContentLength="2147483647" 
                    maxArrayLength="2147483647" 
                    maxBytesPerRead="2147483647" 
                    maxNameTableCharCount="2147483647"/>
    </binding>
  </basicHttpBinding>
</bindings>
<client>
  <endpoint address="https://integrationmdl.grangeinsurance.com/lifequote/LoggingServiceHost/DotNetLoggingServiceHost.svc" 
            binding="basicHttpBinding" 
            bindingConfiguration="BasicBinding" 
            name="BasicBinding" 
            contract="LifeEApplication.Services.Contracts.LoggingServiceContract.IDotNetLoggingService"/>

  <endpoint address="https://integrationmdl.grangeinsurance.com/lifequote/OracleTrimarkServiceHost/OracleTrimarkServiceHost.svc" 
            binding="basicHttpBinding" 
            bindingConfiguration="BasicBinding" 
            name="BasicBinding" 
            contract="LifeEApplication.Services.Contracts.OracleServiceContract.IOracleService"/>
</client>

我的函数适用于少量数据,因此我知道这是与
MaxReceivedMessageSize
的大小有关的问题。我尝试的每件事都会导致同样的问题


值得注意的是:当我使用
WCF测试客户机
调试服务时,显示的配置文件没有我在其配置中指定的最大大小

听起来客户端配置需要增加消息大小。右键单击配置文件,选择“编辑WCF配置”,然后更改MaxReceivedMessageSize值

我同意埃什奈德的观点。您需要更改客户端(RateService项目)主Web.config文件下的设置。右键单击它并选择编辑WCF配置。在配置面板下的弹出窗口中,选择Bindings>YourDefinedBinding(例如wsHttpBinding)。然后将MaxReceivedMessageSize更改为2147483647。我希望这能对您有所帮助。

我对WCF配置设置几乎没有经验。如果我正在调试服务本身…为什么没有从服务的webconfig中提取设置?看起来他们好像在默认其他东西。快把我逼疯了!您是在服务器端还是客户端收到此错误?@500 InternalServerError我在调试服务时收到此错误。通过右键单击RateService项目并选择
Debug
,即手动调试。显示的配置是客户端配置。您应该增加服务器上的
MaxReceivedMessageSize
。我想你有权访问服务器配置?@venerik愚蠢的问题…但服务器配置到底在哪里?我正在调试服务,所以我假设服务中的配置是当时的服务器配置。这已经完成(如问题中的配置所示)。如果我正在调试服务…服务器配置在哪里?谁在接收数据?如果你在iis中托管,那么服务虚拟文件夹中有配置文件?我不确定你的意思?我的主要问题是,在通过WCFStorm调试WCF服务时,我不了解“客户端”是什么。一旦我得到风暴本身就是客户端…我只需要在风暴中设置正确的消息大小,我就一切就绪。谢谢您的帮助@eschneider.config我在原始问题中显示的配置文件是RateService Web.config。因此,我已经在那里设置了
MaxReceivedMessageSize
。由于我通过IIS在本地托管此服务,似乎IIS没有在RateService中保留WebConfig的绑定设置。您的客户端是否通过服务引用使用WCF服务?如果是,您是否在客户端手动更新了服务引用,以便所有更改生效?(右键单击您创建的服务引用,然后单击“更新服务引用”。)