问题
I get this exception while creating scope for few tables all those tables are huge in design
<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>
I have made MaxReceivedMessageSize
to 2147483647
but still it is giving me below exception at this line
client.GetTableDescription(scopeName, syncTable)
The maximum message size quota for incoming messages (65536) has been exceeded.
To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.
回答1:
As per this question's answer
You will want something like this:
<bindings> <basicHttpBinding> <binding name="basicHttp" allowCookies="true" maxReceivedMessageSize="20000000" maxBufferSize="20000000" maxBufferPoolSize="20000000"> <readerQuotas maxDepth="32" maxArrayLength="200000000" maxStringContentLength="200000000"/> </binding> </basicHttpBinding> </bindings>
Please also read comments to the accepted answer there, those contain valuable input.
回答2:
You also need to increase maxBufferSize. Also note that you might need to increase the readerQuotas.
回答3:
You need to make the changes in the binding configuration (in the app.config file) on the SERVER and the CLIENT, or it will not take effect.
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding maxReceivedMessageSize="2147483647 " max...=... />
</basicHttpBinding>
</bindings>
</system.serviceModel>
回答4:
If you are using CustomBinding then you would rather need to make changes in httptransport element. Set it as
<customBinding>
<binding ...>
...
<httpsTransport maxReceivedMessageSize="2147483647"/>
</binding>
</customBinding>
回答5:
This worked for me:
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
回答6:
Updating the config didn't work for me, but I was able to edit the binding programmatically:
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;
}
回答7:
You can partially solve the issue by using MTOM (Message Transmission Optimization Mechanism) message encoding as well, The default message encoding mechanism in WCF is Text, which base64 encodes data, Base64 encoding bloats the message size by approximately 33%.
MTOM does not base64 encode data. This also means the additional processing overhead to base64 encode and decode data is removed. Hence, MTOM can significantly improve the overall message transfer performance.
With Text Message encoding, the binary data is base64 encoded and it is embedded in the SOAP envelope. With MTOM, binary data is included as a MIME (Multipurpose Internet Mail Extensions) attachment.
It can be configured like this in the config file.
<bindings>
<wsHttpBinding>
<binding name="wsHttp" messageEncoding="Mtom"
maxReceivedMessageSize="700000">
<readerQuotas maxArrayLength="700000"/>
</binding>
</wsHttpBinding>
</bindings>
You can compare and see, the bytes received with MTOM is significantly less when compared with Text message encoding.
回答8:
My solution was to use the "-OutBuffer 2147483647" parameter in my query, which is part of the Common Parameters. PS C:> Get-Help about_CommonParameters -Full
回答9:
For me, the settings in web.config
/ app.config
were ignored. I ended up creating my binding manually, which solved the issue for me:
var httpBinding = new BasicHttpBinding()
{
MaxBufferPoolSize = Int32.MaxValue,
MaxBufferSize = Int32.MaxValue,
MaxReceivedMessageSize = Int32.MaxValue,
ReaderQuotas = new XmlDictionaryReaderQuotas()
{
MaxArrayLength = 200000000,
MaxDepth = 32,
MaxStringContentLength = 200000000
}
};
来源:https://stackoverflow.com/questions/5459697/the-maximum-message-size-quota-for-incoming-messages-65536-has-been-exceeded