none
MetadataExchangeClient and nametable character count quota

    Question

  •  

    right let's just give em int.MaxValue I figured, but no luck what so ever:
            

    Code Snippet

               WSHttpBinding binding = new System.ServiceModel.WSHttpBinding(SecurityMode.None);
                binding.MaxReceivedMessageSize = int.MaxValue;
                binding.ReaderQuotas.MaxDepth = int.MaxValue;
                binding.ReaderQuotas.MaxArrayLength = int.MaxValue;
                binding.ReaderQuotas.MaxBytesPerRead = int.MaxValue;
                binding.ReaderQuotas.MaxStringContentLength = int.MaxValue;
                binding.ReaderQuotas.MaxNameTableCharCount = int.MaxValue;
            

                MetadataExchangeClient mexClient = new System.ServiceModel.Description.MetadataExchangeClient(binding);
                mexClient.MaximumResolvedReferences = 32;

         //exception.
                MetadataSet metadata = mexClient.GetMetadata(new Uri(mexAddress), MetadataExchangeClientMode.HttpGet);

     

     


    it still blows up in my face with :

    The maximum nametable character count quota (16384) has been exceeded while reading XML data.
    The nametable is a data structure used to store strings encountered during XML processing - long XML documents with non-repeating element names, attribute names and attribute values may trigger this quota.
    This quota may be increased by changing the MaxNameTableCharCount property on the XmlDictionaryReaderQuotas object used when creating the XML reader

     

    The endpoint I am trying to mex, in the server config, I created a custom binding for the mex endpoint, setting the same values as in the code above (in pure fustration of course)

     

    so what else should I look at ?

     

    regards Allan

    Friday, August 24, 2007 2:19 PM

Answers

All replies

  • Can you try this snippet to see if it works?

     

    CustomBinding mexBinding = new CustomBinding(MetadataExchangeBindings.CreateMexHttpBinding());

    for (int i = 0; i < mexBinding.Elements.Count; i++)

    {

        TextMessageEncodingBindingElement textMEBE =

            mexBinding.ElementsIdea as TextMessageEncodingBindingElement;

        if (textMEBE != null)

        {

            textMEBE.ReaderQuotas.MaxArrayLength = textMEBE.ReaderQuotas.MaxBytesPerRead =

                textMEBE.ReaderQuotas.MaxDepth = textMEBE.ReaderQuotas.MaxNameTableCharCount =

                textMEBE.ReaderQuotas.MaxStringContentLength = int.MaxValue;

        }

    }

    MetadataExchangeClient mexClient = new MetadataExchangeClient(mexBinding);

    ...

     

    Friday, August 24, 2007 8:58 PM
  • Carlos,

    it didn't work, same exception, same fustration

     

     

    thanks Allan

    Friday, August 24, 2007 9:27 PM
  • Can you send the full stack trace for the exception? Also, would it be possible to share the WSDL you're trying to consume?

     

    Thank you.

    Friday, August 24, 2007 9:35 PM
  • Hi Carlos,

     

    could you possibly ping me at:

     

    an AT jcsharp DOT net

     

    the wsdl is rather big I've noticed now....then I could give you the information...

     

    thanks allot Allan

     

     

    Saturday, August 25, 2007 7:33 AM
  • Thank you for the WSDL. Unfortunately, this is a bug in our code (the binding you pass is ignored for HTTP-GET). There are a few workarounds; can you see if any of them will work for you?

    Thanks, Carlos.

    Monday, August 27, 2007 5:34 PM
  • Allan,

     

    This is a service problem. Change the properties below default is 65536.

    MaxBufferSize (basicHttp only)

    MaxReceivedMessageSize

     

    You can find them in your Binding config. When you have to many elements you pass this number very quick.

     

    Pieter

    Thursday, January 31, 2008 1:09 PM
  •  Carlos Figueira - MSFT wrote:
    Thank you for the WSDL. Unfortunately, this is a bug in our code (the binding you pass is ignored for HTTP-GET). There are a few workarounds; can you see if any of them will work for you?

    Thanks, Carlos.

    Or the third option: the use of a little reflection. We increased the MaxBytesPerRead property of the XmlDictionaryReaderQuotas of the EncoderDefaults class this way...
    Tuesday, April 8, 2008 1:17 PM
  • Carlos,

    How do I change the EncoderDefaults?

     

    Trond

     

    Thursday, August 14, 2008 12:06 PM
  • This code fixes the quotas:
     
    var smAsm = AppDomain.CurrentDomain.GetAssemblies().First(a => a.FullName.StartsWith("System.ServiceModel,"));  
    var defTy = smAsm.GetType("System.ServiceModel.Channels.EncoderDefaults");  
    var rq = (System.Xml.XmlDictionaryReaderQuotas)defTy.GetField("ReaderQuotas", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic).GetValue(null);  
    rq.MaxArrayLength = int.MaxValue;  
    rq.MaxDepth = int.MaxValue;  
    rq.MaxNameTableCharCount = int.MaxValue;  
    rq.MaxStringContentLength = int.MaxValue; 

    • Proposed as answer by vnisman Wednesday, November 3, 2010 4:37 AM
    Friday, December 19, 2008 9:11 PM
  • This problem seems to be gone in .NET 4 anyway. :)
    Thursday, April 28, 2011 12:07 PM