WCF: The InnerException message was 'Maximum number of items that can be > serialized or deserialized in an object graph is '65536'

StackOverflow https://stackoverflow.com/questions/16850613

Question

I know many have posted the solutions about this, I have tried all of solutions that were posted on the internet but those didn't work for me. In this scenario, I want to consume WCF service from a SharePoint timer job.

I am constantly getting the issue stated below:

The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://test/MyEntry/2010/03:GetResult. 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.

My Server side web.config for SVC is:

<system.serviceModel>
        <bindings>
            <wsHttpBinding>
        <binding name="WSHttpBinding_IVerksamhetService_server" closeTimeout="10:10:00"
            openTimeout="10:10:00" receiveTimeout="10:10:00" sendTimeout="10:10:00"
            bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
            maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
            messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
            allowCookies="false" >
                 <readerQuotas maxDepth="64" maxStringContentLength="2147483647" maxArrayLength="2147483647"
              maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />                  
        </binding>
      </wsHttpBinding>
    </bindings>
      <services>
        <service behaviorConfiguration="SomeService.DeluxeEntryBehavior" name="SomeService.DeluxeEntry">
          <endpoint address="" binding="wsHttpBinding" contract="SomeService.IVerksamhetService" bindingConfiguration="WSHttpBinding_IVerksamhetService_server" >
            <identity>
              <dns value="localhost"/>
            </identity>
          </endpoint>
          <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
        </service>
      </services>
        <behaviors>
            <serviceBehaviors>
                <behavior name="SomeService.DeluxeEntryBehavior">
                      <serviceMetadata httpGetEnabled="true" />
                      <serviceDebug includeExceptionDetailInFaults="true" />          
                      <dataContractSerializer maxItemsInObjectGraph="2147483647" />
                </behavior>
            </serviceBehaviors>
        </behaviors>
    </system.serviceModel>

My client side config (I added this configuration in OWSTIMER.EXE.CONFIG file)

<system.serviceModel>
        <bindings>
            <wsHttpBinding>
                <binding name="WSHttpBinding_IVerksamhetService" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
                    messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
                    allowCookies="false">
                  <readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxDepth="64" maxNameTableCharCount="2147483647" />                  
                </binding>
            </wsHttpBinding>
        </bindings>
        <behaviors>
          <endpointBehaviors>
            <behavior name="ServiceViewEventBehavior">
              <dataContractSerializer maxItemsInObjectGraph="2147483647"/>    
            </behavior>
          </endpointBehaviors>
        </behaviors>
        <client>
            <endpoint address="http://testserver.ivodmz.za/TestService/MyWCF.svc"
                binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IVerksamhetService"
                contract="IVerksamhetService" behaviorConfiguration= "ServiceViewEventBehavior" name="WSHttpBinding_IVerksamhetService">
                <identity>
                    <dns value="localhost" />
                </identity>
            </endpoint>
        </client>       
    </system.serviceModel>

Update:

I have WCF endpoint setting the limit to 65536 but how can make the endpoint to ignore dll behavior and use what is specified in the XML configuration ?

Was it helpful?

Solution

add behavior to congig and aad it to service

<serviceBehaviors>
      <behavior name="DefaultBehavior" MaxItemsInObjectGraph="2147483647">
         <dataContractSerializer maxItemsInObjectGraph="2147483647" />
         <serviceMetadata httpGetEnabled="true" />
         <serviceDebug includeExceptionDetailInFaults="true" />
      </behavior>
</serviceBehaviors> 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top