I get an exception when there are too many objects returned:
The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://.../Contract:GetBlaBlaResult. The InnerException message was 'Maximum number of items that can be serialized or deserialized in an object graph is '65536'. Change the object graph or increase the MaxItemsInObjectGraph quota. '. Please see InnerException for more details.
I’ve looked it up and added under behaviors in the server side:
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483646"/>
...
And in the client side:
<behaviors>
<endpointBehaviors>
<behavior name="maxItems">
<dataContractSerializer maxItemsInObjectGraph="2147483646" />
</behavior>
</endpointBehaviors>
</behaviors>
But it seems that it is ignored and the exception keeps arising.
The thing is I use XmlSerializer (for attributes in the elements):
[ServiceContract(Namespace = "http://BlaBla.com/webservices/BlaBlaService")]
[XmlSerializerFormat(SupportFaults = true)]
public interface IBlaBlaServices
{
[OperationContract]
BlaBlaResponse GetBlaBla(BlaBlaRequestMessage searchBlaBlaRequest);
}
and the exception, as you can see, refers to the dataContractSerializer (and so is the configuration I’ve added above).
Is it the XmlSerializer that mess up the things?
Can somebody advise please?
Thanks a lot :)
Just to make sure, are you applying the MyServiceBehavior behavior to the service definition in the service config and the maxItems behavior to the endpoint definition in the client config (the behaviorConfiguration attribute)?