83

我在为几个表创建范围时遇到了这个异常,所有这些表的设计都很庞大

<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 属性。

4

8 回答 8

115

根据这个问题的答案

你会想要这样的东西:

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

还请阅读对已接受答案的评论,其中包含有价值的输入。

于 2011-03-28T13:33:45.383 回答
23

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

 <customBinding>
    <binding ...>
     ...
     <httpsTransport maxReceivedMessageSize="2147483647"/>
    </binding>
 </customBinding>
于 2015-08-22T09:53:12.427 回答
13

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

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding maxReceivedMessageSize="2147483647 " max...=... />
        </basicHttpBinding>
       </bindings>
</system.serviceModel>
于 2011-03-28T14:39:43.273 回答
13

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

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;
}
于 2017-09-10T08:54:31.720 回答
12

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

于 2011-03-28T13:32:43.903 回答
6

这对我有用:

 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
于 2015-04-10T17:27:20.653 回答
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
    }
};
于 2019-02-12T06:00:41.013 回答
0

我的解决方案是在我的查询中使用“-OutBuffer 2147483647”参数,这是通用参数的一部分。PS C:> Get-Help about_CommonParameters -Full

于 2015-08-19T18:32:24.913 回答