locked
“The maximum string content length quota (8192) has been exceeded while reading XML data. RRS feed

  • Question

  • First of all I'm a novice on WCF  so the problem must be a obvious one because of the lack of knowledge, so please be patient.  

    I'll present my points:

    • I have a WCF service that returns a string formatted on Json.  I use the Json .Net Library for that purpose.

     

    public string ObtenerProductosTerminadosPorCategoria2(int pCodigoRestaurante, long pCodigoCategoria)
            {
                ProductoBL _productoBL = new ProductoBL();
    
                return JsonConvert.SerializeObject(ConvertirProductoEntidadEnPoco(_productoBL.ObtenerProductosTerminadosPorCategoria(pCodigoRestaurante, pCodigoCategoria)),Formatting.Indented);
    
            }
    

     

    • If I use another function that returns a list of POCO objects the service works perfectly, but in the requirements I must use Json.
    • If I return a very large amount of data the service brings me the error:  “The maximum string content length quota (8192) has been exceeded while reading XML data. This happens on my local environment.
    • I have readed some ways to resolve it on Internet but the error still occur.  I configured a new binding called LargeBuffer who sets the size of the messages and a reader quotas values to it.  Finally my endpoint use that binding and use LargeBuffer as bindingConfiguration.  
    • The service compiles and all the binaries are stored on the local IIS that I'm using.

    My app config text is:

     

     <!-- When deploying the service library project, the content of the config file must be added to the host's 
      app.config file. System.Configuration does not support config files for libraries. -->
      <system.serviceModel>
        <bindings>
          <basicHttpBinding>
            <binding name="LargeBuffer" maxReceivedMessageSize="2147483647">
              <!--70MB-->
              <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
                  maxArrayLength="2147483647" maxBytesPerRead="2147483647"
                  maxNameTableCharCount="2147483647" />
            </binding>
          </basicHttpBinding>
        </bindings>
        
        <services>
          <service name="CARSA.Express.Servicios.CarsaExpress">
            <endpoint address="" binding="basicHttpBinding" bindingConfiguration="LargeBuffer"  contract="CARSA.Express.Servicios.ICarsaExpress"   >
              <identity>
                <dns value="localhost" />
              </identity>
            </endpoint>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
            <host>
              <baseAddresses>
                <add baseAddress="http://localhost:8732/Design_Time_Addresses/CARSA.Express.Servicios/Service1/" />
              </baseAddresses>
            </host>
            
          </service>
         
        </services>

    Hope that someone tells me what is wrong, thanks in advance

     

     

     

     





    • Edited by Hugo Aguero Tuesday, September 13, 2011 5:41 PM
    Tuesday, September 13, 2011 5:37 PM

Answers

All replies

  • not sure if this is out to lunch for your issue or not ... dug this out trying to solve the same error... still stumped with it...  this may help....  hope it does...

    <system.web.extensions>

    <scripting>

    <webServices>

    <jsonSerialization maxJsonLength="2147483644" />

    </webServices>

    </scripting>

    </system.web.extensions>

    Tuesday, September 13, 2011 6:19 PM
  •  
    Well, if you did it on the client side, you most likely have make the
    same changes on the service side. You have to make a new binding on the
    service side and point to the new binding on the service end-point to
    override the default settings.
     
    • Marked as answer by Hugo Aguero Monday, September 19, 2011 6:05 PM
    Tuesday, September 13, 2011 7:52 PM
  • Thanks for the response, I'm very new with WCF can you bring me a good  link explaining the process using IIS 7?
    Friday, September 16, 2011 5:07 PM
  • On 9/16/2011 1:07 PM, Hugo Aguero wrote:
    > Thanks for the response, I'm very new with WCF can you bring me a good
    > link explaining the process using IIS 7?
     
    It's not about IIS7. It's about how to change the default settings on
    the WCF service-side config for readerquota parameters. You did it on
    the client side. It may need to be done on the service side, since the
    data travels between WCF client and WCF service.
     
     
     
    Friday, September 16, 2011 5:26 PM
  • Thanks for the guidance. I finally get it working.

    People who wants a simple way to testing on the local environment can  edit the config file on the WCF Test Client Tool as is described by Herve Roggero on this link: 

    http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/dde72fbe-e741-48fd-a9e1-253800d5227a/http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/dde72fbe-e741-48fd-a9e1-253800d5227a/

     

    The configuration must be set each time the service is tested but at least we can do something .

     

     

    • Marked as answer by Hugo Aguero Monday, September 19, 2011 6:06 PM
    Monday, September 19, 2011 6:05 PM