超出了传入邮件的最大邮件大小配额(65536)


74

在为几个表创建作用域时遇到了这个异常,所有这些表在设计上都非常庞大

<bindings>
    <wsHttpBinding>
        <binding name="wsHttpBinding_ISyncServices" closeTimeout="00:10:00"
            openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
            transactionFlow="false" hostNameComparisonMode="StrongWildcard"
            maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
            <readerQuotas maxDepth="32" maxStringContentLength="2147483647"
                maxArrayLength="2147483647" maxBytesPerRead="2147483647"
                maxNameTableCharCount="2147483647" />
            <reliableSession ordered="true" inactivityTimeout="00:10:00"
                enabled="false" />
            <security mode="Message">
                <transport clientCredentialType="Windows"
                    proxyCredentialType="None" realm="">
                    <extendedProtectionPolicy policyEnforcement="Never" />
                </transport>
                <message clientCredentialType="Windows"
                    negotiateServiceCredential="true" algorithmSuite="Default" />
            </security>
        </binding>
    </wsHttpBinding>
</bindings>

我已经做出MaxReceivedMessageSize了2147483647,但仍然在这一行给了我以下异常

 client.GetTableDescription(scopeName, syncTable)

超出了传入消息的最大消息大小配额(65536)。
要增加配额,请在适当的绑定元素上使用MaxReceivedMessageSize属性。




Answers:


109

根据这个问题的答案

您将需要这样的东西:

<bindings>
     <basicHttpBinding>
         <binding name="basicHttp" allowCookies="true"
 maxReceivedMessageSize="20000000"
 maxBufferSize="20000000"
 maxBufferPoolSize="20000000">
             <readerQuotas maxDepth="32"
 maxArrayLength="200000000"
 maxStringContentLength="200000000"/>
         </binding>
     </basicHttpBinding> </bindings>

另请在此处阅读对已接受答案的评论,其中包含宝贵的意见。


15

如果您使用的是CustomBinding,则需要在httptransport元素中进行更改。设置为

 <customBinding>
    <binding ...>
     ...
     <httpsTransport maxReceivedMessageSize="2147483647"/>
    </binding>
 </customBinding>

1
我希望我能对此100X投票。我不知道我的WCF配置浪费了多少小时。
McGuireV19年

是的,您也为我节省了很多时间
TSmith

12

您还需要增加maxBufferSize。另请注意,您可能需要增加readerQuotas


为什么Visual Studio将'maxBufferSize'标记为不允许?我有VS 2010
FrenkyB

5
对于未来的访问者:maxBufferSize必须匹配maxReceivedMessageSize,否则可能会引发错误。
AgentFire

11

您需要在SERVER和CLIENT上的绑定配置(在app.config文件中)中进行更改,否则更改不会生效。

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding maxReceivedMessageSize="2147483647 " max...=... />
        </basicHttpBinding>
       </bindings>
</system.serviceModel>

30
这个答案从字面上使我大声笑了:)
Carrie Kendall 2014年

1
但这是真的。在更改客户端设置之前,我遇到了同样的问题。那还可以。
FrenkyB 2015年

1
如果有人会有类似的问题。我已经在WCF上进行了所有设置,但仍收到错误消息。在客户端上,我在下面添加了代码,然后确定。非常感谢@CarrieKendall。<system.serviceModel> <bindings> <wsHttpBinding> <binding name =“ WSHttpBinding_ISotechWcfForWebService” maxBufferPoolSize =“ 2147483647” maxReceivedMessageSize =“ 2147483647”> <security mode =“ None” /> </ binding> </ wsHttpBinding> </ bindings>
FrenkyB 2015年

1
服务器端的代码设置相同:BasicHttpBinding bind01 = new BasicHttpBinding(); bind01.Security.Mode = BasicHttpSecurityMode.None; bind01.Security.Transport.ClientCredentialType = HttpClientCredentialType.None; bind01.MaxReceivedMessageSize = int.MaxValue; bind01.MaxBufferPoolSize = int.MaxValue; bind01.MaxBufferSize = int.MaxValue; bind01.ReaderQuotas.MaxDepth = 32; bind01.ReaderQuotas.MaxArrayLength = int.MaxValue; bind01.ReaderQuotas.MaxStringContentLength = int.MaxValue; bind01.ReceiveTimeout = new TimeSpan(0,10,0);
FrenkyB

在客户端添加maxReceivedMessageSize =“ 2147483647”解决了我的问题。谢谢
selectedOne Thabs

8

更新配置对我不起作用,但是我可以通过编程方式编辑绑定:

private YourAPIClient GetClient()
{
    Uri baseAddress = new Uri(APIURL);

    var binding = new BasicHttpBinding();
    binding.MaxReceivedMessageSize = 20000000;
    binding.MaxBufferSize = 20000000;
    binding.MaxBufferPoolSize = 20000000;
    binding.AllowCookies = true;

    var readerQuotas = new XmlDictionaryReaderQuotas();
    readerQuotas.MaxArrayLength = 20000000;
    readerQuotas.MaxStringContentLength = 20000000;
    readerQuotas.MaxDepth = 32;
    binding.ReaderQuotas = readerQuotas;

    if (baseAddress.Scheme.ToLower() == "https")
        binding.Security.Mode = BasicHttpSecurityMode.Transport;

    var client = new YourAPIClient(binding, new EndpointAddress(baseAddress));
    return client;
}

1
您将其放在WCF服务的哪一部分?
马尔科姆·萨尔瓦多

@ Malky.Kid我创建了此客户端,以调用基于.net的肥皂网络服务。
p_champ

5

这为我工作:

 Dim binding As New WebHttpBinding(WebHttpSecurityMode.Transport)
 binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None
 binding.MaxBufferSize = Integer.MaxValue
 binding.MaxReceivedMessageSize = Integer.MaxValue
 binding.MaxBufferPoolSize = Integer.MaxValue

1
您在哪里放置这个?上课?
马尔科姆·萨尔瓦多

0

我的解决方案是在查询中使用“ -OutBuffer 2147483647”参数,该参数是“通用参数”的一部分。PS C:>获取帮助about_CommonParameters-完整


0

对我来说,web.config/app.config中的设置被忽略了。我最终手动创建了绑定,这为我解决了这个问题:

var httpBinding = new BasicHttpBinding()
{
    MaxBufferPoolSize = Int32.MaxValue,
    MaxBufferSize = Int32.MaxValue,
    MaxReceivedMessageSize = Int32.MaxValue,
    ReaderQuotas = new XmlDictionaryReaderQuotas()
    {
        MaxArrayLength = 200000000,
        MaxDepth = 32,
        MaxStringContentLength = 200000000
    }
};
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.