views:

26

answers:

1

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 :)

+1  A: 

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)?

JeffN825
Yes, although it seems to me strange because it's supposed to be cross-platforms and the idea to tell the client how to config its side looks awkward.
graumanoz
Yes, indeed, it is a bit awkward. If you apply the ServiceBehavior attribute to set the MaxItemsInGraph does that work? [ServiceBehavior(MaxItemsInObjectGraph = 2147483646)] (on the Service implementation, not the contract).
JeffN825
Thanks Jeffn825 for your attention :)Setting the behavior was the solution after all and the XmlSerializer have nothing to do with the problem.I just got it wrong with the behavior name...
graumanoz