When you use the "Add Service Reference" to generate the client for the WCF service, this tool adds the information necessary for the client to communicate with the server in its configuration file (app.config or web.config). One of them is binding
to be used.
You can change the binding
setting to increase this quota that the error message is saying is being exceeded. For example:
<bindings>
<basicHttpBinding>
<binding
name="BasicHttpBinding_MyService"
maxReceivedMessageSize="1000000" />
</basicHttpBinding>
</bindings>
Another alternative is to do this in code, before calling a client function for the first time, as in the example below.
var c = new ServiceReference1.MyServiceClient();
var binding = c.Endpoint.Binding;
if (binding is BasicHttpBinding)
{
((BasicHttpBinding)binding).MaxReceivedMessageSize = 1000000;
}
else if (binding is WSHttpBinding)
{
((WSHttpBinding)binding).MaxReceivedMessageSize = 1000000;
}
else
{
// outros tipos
var newBinding = new CustomBinding(binding);
for (var i = 0; i < newBinding.Elements.Count; i++)
{
if (newBinding.Elements[i] is TransportBindingElement) {
((TransportBindingElement)newBinding.Elements[i]).MaxReceivedMessageSize = 1000000;
}
}
c.Endpoint.Binding = newBinding;
}