none
Maximum size data transferred by WCF

    Question

  • Hi,

    I have a WCF service that creates an Ilist of custom entities; with about 5000 entities, all works, but with a larger number,

    when, from the client, i tried to retrieve this list, it gives me the error "The remote server returned an unexpected response: (404) Not Found".

    So I searched on google about this common problem and I set, in the ServiceConfiguration.ClientConfig, maxBufferSize="2147483647"      maxReceivedMessageSize="2147483647"> 

    but it is not enough.

     So, what could I do? 

    There is another way to "automatically split" the data over the wire?

    Thank you very much

    Thursday, July 23, 2009 11:11 AM

Answers

  •  Hi,

    I think you are hitting the limit for maxItemsInObjectGraph for dataContractSerializer. Try the following under the service behavior section of your web.config:

     

        <behaviors>
    <serviceBehaviors>
    <behavior name="SilverlightApplication.Web.SilverlightWCFServiceBehavior">
    <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
    </behavior>
    </serviceBehaviors>
    </behaviors>
      

    Also, have a look at this post.

     Hope that helps.

     

    Regards ,

    Friday, July 24, 2009 3:37 AM

All replies

  •  i seriously doubt you're exceeding 2 gigs of data.

    make sure you're setting those values in the appropriate place in web.config as well.  with binary encoding it looks like this:

         <bindings>
          <customBinding>
            <binding name="binary">
              <binaryMessageEncoding/>
              <httpTransport maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"/>
            </binding>
          </customBinding>
        </bindings>

    Thursday, July 23, 2009 11:37 AM
  •  Ok, thanks, I'll try with the setting you wrote me.

    What about the ServiceReferences.ClientConfig file? What configuration have I to have inside? 

    Thank you

    Thursday, July 23, 2009 11:41 AM
  •  i'm pretty sure that file is autogenerated when you add/update your service reference.  you shouldn't have to change it.

    Thursday, July 23, 2009 1:02 PM
  • It doesn't work!

    Maybe the problem is in the data structure I use? 

    I'm using an Ilist of custom entities, each one with 8 primitive type properties.

    I don't know what to do.

    Friday, July 24, 2009 3:23 AM
  •  Hi,

    I think you are hitting the limit for maxItemsInObjectGraph for dataContractSerializer. Try the following under the service behavior section of your web.config:

     

        <behaviors>
    <serviceBehaviors>
    <behavior name="SilverlightApplication.Web.SilverlightWCFServiceBehavior">
    <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
    </behavior>
    </serviceBehaviors>
    </behaviors>
      

    Also, have a look at this post.

     Hope that helps.

     

    Regards ,

    Friday, July 24, 2009 3:37 AM
  •  Thank you!!!!!

    It works now!!

    Friday, July 24, 2009 3:57 AM
  • HI,

    You can also use this (Put this just before <system.serviceModel> tag):

    <runtime>

    <binding name="FileTransferServicesBinding" closeTimeout="00:10:00" openTimeout="00:20:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" transferMode="Streamed" messageEncoding="Mtom" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" MaxArrayLenght="2147483647" MaxBytesPerRead="2147483647" MaxDepth="2147483647" MaxNameTableCharCount="2147483647">

    <security mode="None">

    <transport clientCredentialType="None"/>

    </security>

    </binding>

    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

    <dependentAssembly>

    <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>

    <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>

    </dependentAssembly>

    <dependentAssembly>

    <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>

    <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>

    </dependentAssembly>

    </assemblyBinding>

    </runtime>

    You can use this for all the service (no need to put the same for each service).

    HTH Smile

    Friday, July 24, 2009 5:58 AM
  • Excellent Post! Thanks for this.

    Tuesday, August 18, 2009 8:40 AM
  •  Does this mean you can use MTOM with Sliverlight

    Friday, September 25, 2009 8:14 PM
  • Hi

    This just shows you where to configure a propery that will allow larger soap messages to pass through your WCF service.

    To answer your question, yes you can use MTOM in your Silverlight WCF service.

    Here is a nice example I tested from a Silverlight app..

    http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/1810d663-0e9c-4c83-9a1b-1b5793bd9e7b

     

    Saturday, September 26, 2009 10:58 AM
  •  

    Hi

    This just shows you where to configure a propery that will allow larger soap messages to pass through your WCF service.

    To answer your question, yes you can use MTOM in your Silverlight WCF service.

    Here is a nice example I tested from a Silverlight app..

    http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/1810d663-0e9c-4c83-9a1b-1b5793bd9e7b

     

     Hi I'm trying to use MTOM for my silverlight application, but when i set a service reference to an MTOM service, the ServiceReferences.ClientConfig was not updated. Probably because the message encoding attribute is not supported by Silverlight. How did you configure the MTOM service to be used by Silverlight?

    Thanks.

    Friday, April 02, 2010 10:55 AM