WCF返回请求实体太大

时间:2018-08-02 09:30:44

标签: c# wcf

传递字节数组(10,000个项目)时出现以下错误,我在这里错过了什么?

这是我的服务器的配置。我将所有缓冲区安装到最大值

 <system.serviceModel>

<bindings>
    <basicHttpBinding>
        <binding name="New" closeTimeout="01:00:00" openTimeout="01:00:00" receiveTimeout="01:00:00" sendTimeout="01:00:00" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
            <readerQuotas maxDepth="200000000" maxBytesPerRead="200000000" maxArrayLength="200000000" maxStringContentLength="200000000" />
        </binding>
    </basicHttpBinding>
</bindings>

<services>
  <service name="Service">
    <endpoint address="EFCore.Contract.General.AircraftService" binding="basicHttpBinding" contract="EFCore.Contract.General.IAircraftService" bindingConfiguration="New" />
    <endpoint address="EFCore.Contract.Dictionaries.FlightNumService" binding="basicHttpBinding" contract="EFCore.Contract.Dictionaries.IFlightNumService" bindingConfiguration="New" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:45617" />
      </baseAddresses>
    </host>
  </service>
</services>
  <behaviors>
      <serviceBehaviors>
          <behavior>
              <dataContractSerializer maxItemsInObjectGraph="2147483647" />
              <serviceMetadata httpGetEnabled="true" />
              <serviceDebug includeExceptionDetailInFaults="true" />
          </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
          <behavior>
              <dataContractSerializer maxItemsInObjectGraph="2147483647" />
          </behavior>
      </endpointBehaviors>
  </behaviors>
  <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https" />
  </protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />

在客户端,我连接了fromCode。一切正常。但是,当我调用service方法并传递一个数组(项数大于5000)时,出现错误:

  

远程服务器返回了意外的响应:(413)请求   实体太大。

_binding = new BasicHttpBinding
        {
            CloseTimeout = new TimeSpan(1, 0, 0),
            OpenTimeout = new TimeSpan(1, 0, 0),
            ReceiveTimeout = new TimeSpan(1, 0, 0),
            SendTimeout = new TimeSpan(1, 0, 0),
            MaxBufferPoolSize = 2147483647,
            MaxBufferSize = 2147483647,
            MaxReceivedMessageSize = 2147483647,
            TransferMode = TransferMode.Buffered,
            ReaderQuotas =
            {
                MaxArrayLength = 200000000,
                MaxBytesPerRead = 200000000,
                MaxDepth = 200000000,
                MaxStringContentLength = 200000000
            }
        };endPoint = new EndpointAddress("http://91.213.233.139:45617/Servicies/AircraftService.svc");
            var channelFactoryFoo = new ChannelFactory<IAircraftService>(_binding, endPoint);
            return (IRepository<T>) channelFactoryFoo.CreateChannel();

1 个答案:

答案 0 :(得分:0)

使用this 增加邮件大小配额