如何以编程方式设置MaxItemsInObjectGraph

时间:2010-11-01 19:13:31

标签: wcf

这就是我从代码

配置客户端的方法
    var binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly);
    binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
    binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;

    binding.MaxBufferSize = Int32.MaxValue;
    binding.MaxReceivedMessageSize = Int32.MaxValue;
    binding.ReaderQuotas.MaxDepth = Int32.MaxValue;
    binding.ReaderQuotas.MaxStringContentLength = Int32.MaxValue;
    binding.ReaderQuotas.MaxArrayLength = Int32.MaxValue;
    binding.ReaderQuotas.MaxBytesPerRead = Int32.MaxValue;
    binding.ReaderQuotas.MaxNameTableCharCount = Int32.MaxValue;


    BnsApiClient client = new BnsApiClient(binding, new EndpointAddress("http://mysite/Hello.svc"));