A call to a web service is returning this message:
System.ServiceModel.CommunicationException: 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.
Am I missing something? I believe I am setting all of the relevant WCF message size parameters to their largest possible values. I have the settings below in both the client (web application calling the web service) and the web service itself.
In both configuration files this is the only binding defined, and the selected binding in both the client and service endpoints has this attribute:
binding="netTcpBinding"
The binding tag contains:
<netTcpBinding>
<binding name="netTcpBinding"
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
...
<serviceBehaivors...behavior>
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
I used the DataContractSerializer
and manually serialized a return value that causes the above error, like so:
DataContractSerializer dcs = new DataContractSerializer(typeof(List<MyObject>));
using (Stream stream = new MemoryStream())
{
dcs.WriteObject(stream, list);
Console.WriteLine(stream.Length);
}
The value written to the screen is "443235", which I am guessing is the approximate size of the wcf message. I don't understand where this error is coming from, or how to stop it from happening, any advice is appreciated.
You need to use the bindingConfiguration
attribute in the endpoint
element and assign it the name of the appropriate binding configuration. All binding
tells the endpoint is what type of binding to use, and without a related bindingConfiguration
it will use the default values for the binding.
So in your endpoint, you would do something like this:
<endpoint address=""
binding="netTcpBinding"
bindingConfiguration="netTcpBinding"
contract="IMyService" />
Now your end point will pick up the values you defined for the NetTcpBinding
protocol in the configuration section named "netTcpBinding".