quinta-feira, 29 de agosto de 2013

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.


OK, that's the problem.

The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:ObterSituacaoClienteGrupoResult. 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.

First of all, this message was received by the client of the service. So, the issue has two sides: client and server.

The server side

On the server side you're gonna have to add a new property to your behaviour.

Example



  <system.serviceModel>

    <behaviors>

      <serviceBehaviors>
        <behavior name="MyBehaviour">
          <serviceMetadata httpGetEnabled="False" httpsGetEnabled="True"/>
          <serviceDebug includeExceptionDetailInFaults="False"/>
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
        </behavior>
    <services>


      <service behaviorConfiguration="MyBehaviour" name="Netdaniels.Services.Rating">
        <endpoint address="" binding="netTcpBinding" bindingConfiguration="MyBehaviour" bindingNamespace="http://www.netdaniels.com.br/product/risk/v1" contract="Netdaniels.Contract.IRisk" />



        <host>
          <baseAddresses>
            <add baseAddress="/Risk.svc" />
          </baseAddresses>
        </host>
      </service>

Unfortunately you have to change the client site too.

The client side

Example

<system.serviceModel>
<behaviors>
      <endpointBehaviors>
        <behavior name="MyBehaviour">
          <dataContractSerializer maxItemsInObjectGraph="2147483646" />
        </behavior>
      </endpointBehaviors>
</behaviors>

      <endpoint address="net.tcp://serverofclient:10261/Netdaniels.MyClient/shaba/"
                binding="netTcpBinding" behaviorConfiguration="MyBehaviour" bindingConfiguration="NetTcpBinding_IShaba"
                contract="ServicesNetdaniels.IShaba" name="NetTcpBinding_IShaba">
        <identity>
          <servicePrincipalName value="host/serverofclient" />
        </identity>
      </endpoint>

This is one of the most annoying problems I ever had.

I don't know if you noticed but there's a ripple effect related to this problem.

SERVER1 <- CLIENT 1 <- CLIENT 2 <- CLIENT 3

The scheme above means that, if you change configuration of server 1 you'll have to change configuration of client 1. If client 1 has a client, the configuration of this one must be changed too ans so on.

That's all folks!








Nenhum comentário:

Postar um comentário