MetadataExchangeClient and nametable character count quota
-
Friday, August 24, 2007 2:19 PM
right let's just give em int.MaxValue I figured, but no luck what so ever:
Code SnippetWSHttpBinding 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 readerThe 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
Answers
-
Monday, August 27, 2007 5:34 PM
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?-
Is the service a WCF service? If so, can you enable a mex endpoint on the service? The binding will be used work for the mex endpoint.
-
Can you use the Discovery protocol (http://msdn2.microsoft.com/en-us/library/system.web.services.discovery.discoveryclientprotocol.aspx) to get the metadata from your service? The XML readers used by this class don’t have any quotas.
Thanks, Carlos.
-
All Replies
-
Friday, August 24, 2007 8:58 PM
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.Elements
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 9:27 PM
Carlos,
it didn't work, same exception, same fustration
thanks Allan
-
Friday, August 24, 2007 9:35 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.
-
Saturday, August 25, 2007 7:33 AM
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
-
Monday, August 27, 2007 5:34 PM
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?-
Is the service a WCF service? If so, can you enable a mex endpoint on the service? The binding will be used work for the mex endpoint.
-
Can you use the Discovery protocol (http://msdn2.microsoft.com/en-us/library/system.web.services.discovery.discoveryclientprotocol.aspx) to get the metadata from your service? The XML readers used by this class don’t have any quotas.
Thanks, Carlos.
-
-
Thursday, January 31, 2008 1:09 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
-
Tuesday, April 08, 2008 1:17 PMOr the third option: the use of a little reflection. We increased the MaxBytesPerRead property of the XmlDictionaryReaderQuotas of the EncoderDefaults class this way...
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? -
Is the service a WCF service? If so, can you enable a mex endpoint on the service? The binding will be used work for the mex endpoint.
-
Can you use the Discovery protocol (http://msdn2.microsoft.com/en-us/library/system.web.services.discovery.discoveryclientprotocol.aspx) to get the metadata from your service? The XML readers used by this class don’t have any quotas.
Thanks, Carlos.
-
-
Thursday, August 14, 2008 12:06 PM
Carlos,
How do I change the EncoderDefaults?
Trond
-
Friday, December 19, 2008 9:11 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 03, 2010 4:37 AM
-
Thursday, April 28, 2011 12:07 PMThis problem seems to be gone in .NET 4 anyway. :)

