zoukankan      html  css  js  c++  java
  • WCF:读取 XML 数据时,超出最大字符串内容长度配额 (8192)。通过更改在创建 XML 读取器时所使用的 XmlDictionaryReaderQuotas 对象的 MaxStringContentLength 属性,可增加此配额。

    使用WCF传输大数据时,我们都会碰到如题中出现的错误信息,出现这个问题是因为WCF本身的安全机制导致的,限制了客户端与服务器资源传输大小,那我们如何还解决这个问题呢?

    针对这个问题,我们要分发送、接受两个方面来解决。

    发送大数据:在WCF服务端解决

                     NetTcpBinding binding =  new NetTcpBinding();

          binding.MaxReceivedMessageSize= 2147483647(更改这个数字) ;

    接受大数据:在WCF客户端解决

          NetTcpBinding binding =  new NetTcpBinding();

          binding.ReaderQuotas = new XmlDictionaryReaderQuotas() { MaxStringContentLength = 2147483647(更改这个数字) };


    我们即可以使用如上述通过代码配置,我们同样也可以使用配置文件进行配置(在binding节中)。

    public static System.ServiceModel.BasicHttpBinding Binding()
            {
                //读取 XML 数据时,超出最大字符串内容长度配额 (8192)。
                System.ServiceModel.BasicHttpBinding bing = new System.ServiceModel.BasicHttpBinding();
                bing.ReaderQuotas = new System.Xml.XmlDictionaryReaderQuotas() { MaxStringContentLength = 2147483647 }; //(更改这个数字) 
                return bing;
            }
    public static API.iClient api = new API.iClient(Binding(), new System.ServiceModel.EndpointAddress("http://192.168.1.11:4417/WebService.svc"));  
  • 相关阅读:
    CSS自定义三角形
    完整例子-正则控制input的输入
    vux环境配置
    纯JS实现加载更多(VUE框架)
    随时监测屏幕大小,解决手机端小键盘遮挡输入框问题
    [转]Javascript中几种较为流行的继承方式
    使用字面量,比new更加有效
    2.ES6引进的新特性——类Class
    vue-router 基本使用
    插槽slot
  • 原文地址:https://www.cnblogs.com/Fooo/p/2805362.html
Copyright © 2011-2022 走看看