When you use the "Add Service Reference" to generate the client for the WCF service, this tool adds in your configuration file (app.config or web.config) the information necessary for the client to communicate with the server. One of them is the binding
to be used.
You can change the configuration of binding
to increase this share 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 the 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;
}
You must increase the property
maxReceivedMessageSize
in thebinding
of your customer. How is your customer defined? UsingChannelFactory
directly, using a class generated byAdd Service Reference
, in some other way?– carlosfigueira
Carlos, is defined by the class generated by the Add Service Reference
– Diego Augusto
I increased the property maxReceivedMessageSize, maxBufferSiz,maxBufferPoolSize and it worked, thank you !
– Diego Augusto