已超出传入邮件的最大邮件大小限额(65536)

Onk*_*kar 66 wcf basichttpbinding

我为几个表创建范围时得到了这个异常,所有这些表都是巨大的设计

<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>
Run Code Online (Sandbox Code Playgroud)

我已经做到MaxReceivedMessageSize2147483647,但它仍然在这条线下给我以下例外

 client.GetTableDescription(scopeName, syncTable)
Run Code Online (Sandbox Code Playgroud)

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

Seb*_*ada 103

按照这个问题的答案

你会想要这样的东西:

<bindings>
     <basicHttpBinding>
         <binding name="basicHttp" allowCookies="true"
 maxReceivedMessageSize="20000000"
 maxBufferSize="20000000"
 maxBufferPoolSize="20000000">
             <readerQuotas maxDepth="32"
 maxArrayLength="200000000"
 maxStringContentLength="200000000"/>
         </binding>
     </basicHttpBinding> </bindings>
Run Code Online (Sandbox Code Playgroud)

还请阅读那里接受的答案的评论,其中包含有价值的意见.


RQD*_*QDQ 12

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

  • 对于未来的访问者:`maxBufferSize`必须匹配`maxReceivedMessageSize`,否则可能会抛出错误. (4认同)

p_c*_*amp 12

更新配置对我不起作用,但我能够以编程方式编辑绑定:

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;
}
Run Code Online (Sandbox Code Playgroud)


fla*_*ayn 9

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

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding maxReceivedMessageSize="2147483647 " max...=... />
        </basicHttpBinding>
       </bindings>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)

  • 这个答案字面上让我笑得很开心:) (30认同)

Sof*_*tec 9

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

__CODE__

  • 我希望我能投票 100 倍。我想知道我的 WCF 配置浪费了多少时间。 (5认同)

Den*_*nis 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
Run Code Online (Sandbox Code Playgroud)