相关疑难解决方法(0)

WCF - 如何增加邮件大小配额

我有一个WCF服务,它从数据库返回1000条记录到客户端.我有一个ASP.NET WCF客户端(我在asp.net Web应用程序项目中添加了服务引用以使用WCF).

运行客户端应用程序时收到以下消息:

已超出传入邮件的最大邮件大小限额(65536).要增加配额,请在相应的绑定元素上使用MaxReceivedMessageSize属性.

有帮助吗?如何增加邮件大小配额?

.net asp.net wcf .net-3.5

447
推荐指数
11
解决办法
41万
查看次数

从C#调用WCF时如何增加MaxReceivedMessageSize

可能重复:
已超出传入邮件的最大邮件大小限额(65536)

我正在使用WCF进行文件上传和下载.上传成功但是当我下载一个大文件时,我发现了这个错误

错误:已超出传入邮件的最大邮件大小限额(65536).要增加配额,请在相应的绑定元素上使用MaxReceivedMessageSize属性.

我的Service.config文件具有以下代码.

<system.web>
    <compilation debug="true" />
    <httpRuntime executionTimeout="4800" maxRequestLength="2147483647" />


  </system.web>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferPoolSize="524288">
          <readerQuotas maxDepth="32" maxStringContentLength="2147483647" 
            maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"  />
        </binding>
      </basicHttpBinding>
      <!--<webHttpBinding>
        <binding maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" />
      </webHttpBinding>-->
    </bindings>
    <services>
      <service name="WITSService.WITSService">
        <clear />
        <endpoint binding="basicHttpBinding" contract="WITSService.WITSService" />
      </service>
    </services>

    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
          <dataContractSerializer maxItemsInObjectGraph="2147483646"/>
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="myEndPointBehavior">
          <dataContractSerializer maxItemsInObjectGraph="2147483646"/>
        </behavior>
      </endpointBehaviors>
    </behaviors>

    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
Run Code Online (Sandbox Code Playgroud)

任何人都可以帮助我如何增加MaxReceivedMessageSize

.net c# asp.net wcf web-services

25
推荐指数
2
解决办法
15万
查看次数

传入邮件的最大邮件大小限额(65536)....要增加配额,请使用MaxReceivedMessageSize属性

我遇到了这个我正在努力处理的疯狂问题.我知道当我们获取大量数据时,我们必须增加客户端.config文件的配额,但如果我的客户端向WCF服务器发送大量数据,我应该怎么做?

当我发送小尺寸输入参数时,它完全正常.不幸的是,当输入变大时,它会崩溃.

调试器说:

错误请求,400;

在跟踪文件上它是:

已超出传入邮件的最大邮件大小限额(65536).要增加配额,请在相应的绑定元素上使用MaxReceivedMessageSize属性.

是否有某种方法可以增加服务器端的数据配额?如果是这样,怎么样?

这是我的示例配置相关部分:

<bindings>
  <basicHttpBinding>
    <binding name="MyBasicHttpBinding"
        closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00"
        sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false"
        hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647"
        maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
        messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
        useDefaultWebProxy="true">
      <readerQuotas maxDepth="64" maxStringContentLength="2147483647" maxArrayLength="2147483647"
          maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"  />
      <security mode="None">
        <transport clientCredentialType="None" proxyCredentialType="None"
            realm="" />
        <message clientCredentialType="UserName" algorithmSuite="Default" />
      </security>
    </binding>

  </basicHttpBinding>
</bindings>

 <services>
  <service name="MyWcfService">
    <endpoint address="http://myservice..."
      binding="basicHttpBinding" bindingConfiguration="MyBasicHttpBinding"
      name="MyBasicHttpBinding" contract="IMyContract" />
  </service>
</services> 
Run Code Online (Sandbox Code Playgroud)

这是我的客户端代码(我动态创建):

        var binding = new BasicHttpBinding();
        binding.MaxBufferPoolSize = 2147483647;
        binding.MaxBufferSize = 2147483647;
        binding.MaxReceivedMessageSize = 2147483647;
        binding.ReaderQuotas.MaxStringContentLength = 2147483647;
        binding.ReaderQuotas.MaxArrayLength = …
Run Code Online (Sandbox Code Playgroud)

wcf server-side request maxreceivedmessagesize

20
推荐指数
3
解决办法
9万
查看次数