tags:

views:

303

answers:

2

When I am trying to read a meta data I got this error any Idea here is My code

WSHttpBinding binding = new WSHttpBinding(SecurityMode.None);
binding.MaxReceivedMessageSize = Int32.MaxValue; // DPNote: This may actually be too big.  see how it performs.
binding.ReaderQuotas.MaxNameTableCharCount = 99999999;

MetadataExchangeClientMode exchangeMode = MetadataExchangeClientMode.HttpGet; // Default to a HttpGET
metaClient = new MetadataExchangeClient(binding);
metaClient.MaximumResolvedReferences = 10 * 100; //DPNote: Some arbitrary number.  Default is 10, so this is bigger.


if (address.Scheme == "http")
  exchangeMode = MetadataExchangeClientMode.HttpGet;
else if (address.Scheme == "https")
  exchangeMode = MetadataExchangeClientMode.HttpGet;
else
  exchangeMode = MetadataExchangeClientMode.MetadataExchange;

MetadataSet metadata = metaClient.GetMetadata(address, exchangeMode);
MetadataImporter importer = new WsdlImporter(metadata);

and this is the line which throws the error

MetadataSet metadata = metaClient.GetMetadata(address, exchangeMode);
A: 

Have you tried incrementing any of these other values inside of binding.ReaderQuotas beyond their default values:

maxDepth, maxStringContentLength, maxArrayLength, maxBytesPerRead?

It could also be the maxBufferPoolSize of the binding

Bryan Denny
still getting the same error :(
BreakHead
Hmm.... Does your server side and client side end points match each other? You might also be missing the mex binding? Look here: http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/d768c591-2b9d-42cb-b27a-9523befe3f0d and here: http://social.msdn.microsoft.com/forums/en-US/wcf/thread/38d09aca-acd3-4eb8-a5d3-803a68de92d9/
Bryan Denny
I can only check this at client side because meta data can be of any foriegn service..
BreakHead
A: 

This is a error in Microsoft code,Http-Get not support Reader Quotas, so we can do this

      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; 
BreakHead