locked
modify endpoint reader quotas programatically RRS feed

  • Question

  • Hi,

    I have a dynamic client to a service. How can i change the ReaderQuotas property of it's endpoint binding?

    I tried like this but it doesn't work ....

     DynamicProxyFactory factory = new DynamicProxyFactory(m_serviceWsdlUri);
             
             foreach (ServiceEndpoint endpoint in factory.Endpoints)
             {
                 Binding binding =  endpoint.Binding;
                
                 binding.GetProperty<XmlDictionaryReaderQuotas>(new BindingParameterCollection()).MaxArrayLength = 2147483647
                 binding.GetProperty<XmlDictionaryReaderQuotas>(new BindingParameterCollection()).MaxBytesPerRead =2147483647;
                 binding.GetProperty<XmlDictionaryReaderQuotas>(new BindingParameterCollection()).MaxDepth = 2147483647;
                 binding.GetProperty<XmlDictionaryReaderQuotas>(new BindingParameterCollection()).MaxNameTableCharCount = 2147483647;
                 binding.GetProperty<XmlDictionaryReaderQuotas>(new BindingParameterCollection()).MaxStringContentLength = 2147483647;
    }

    Even after doing this the ReaderQuotas values remain the default ones.

    I also tried like this and still doesn't work:

    DynamicProxyFactory factory = new DynamicProxyFactory(m_serviceWsdlUri);
             
             foreach (ServiceEndpoint endpoint in factory.Endpoints)
             {
                 System.ServiceModel.Channels.BindingElementCollection bec = endpoint.Binding.CreateBindingElements();

                 System.ServiceModel.Channels.TransportBindingElement tbe = bec.Find<System.ServiceModel.Channels.TransportBindingElement>();

                 tbe.MaxReceivedMessageSize = 2147483647;
                 tbe.MaxBufferPoolSize = 2147483647;
                 TextMessageEncodingBindingElement textBE = bec.Find<TextMessageEncodingBindingElement>();

                 if (textBE != null)
                 {

                     textBE.ReaderQuotas.MaxStringContentLength = 2147483647;
                     textBE.ReaderQuotas.MaxArrayLength = 2147483647;
                     textBE.ReaderQuotas.MaxBytesPerRead = 2147483647;
                     textBE.ReaderQuotas.MaxDepth = 2147483647;
                     textBE.ReaderQuotas.MaxNameTableCharCount = 2147483647;

                 }
    }

    I need this so i can send more than 8kb to the service.

    Need help please, and some example if possible...


    Thanks,
    Adrya
    • Edited by Adrya84 Tuesday, June 9, 2009 11:16 AM
    Tuesday, June 9, 2009 10:59 AM

Answers

  • Here is the solution http://stackoverflow.com/questions/969479/modify-endpoint-readerquotas-programatically
    Maybe it helps someone...
    • Marked as answer by Adrya84 Wednesday, June 10, 2009 8:44 AM
    Wednesday, June 10, 2009 8:43 AM