原文: The maximum string content length quota (8192) has been exceeded while reading XML data

问题场景:在我们WCF服务发布后,我们要确保服务端以及客户端的配置文件允许合适大小的传输设置。笔者在发布WCF服务时,服务端的绑定未做传输大小的设置(采用了默认,maxStringContentLength默认大小为8192),而我们在传输序列化的数据时,大小超过了这个限制。

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

问题原因:服务端或者客户端关于传输大小的未做设置,maxStringContentLength默认大小为8192,实际传输大于8192,由此产生异常。

 

解决方案:

1.确定是客户端还是服务端的限制。

2.在客户端或服务器的做如下配置:

<binding name="xxx" maxReceivedMessageSize="2147483647"><readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647"maxNameTableCharCount="2147483647" />security></binding>

代码中可修改如下:

  MyServiceClient service = null;//MyServiceClient service = new MyServiceClient();try{System.ServiceModel.Channels.CustomBinding bing = new System.ServiceModel.Channels.CustomBinding(new System.ServiceModel.Channels.BindingElement[]{ new BinaryMessageEncodingBindingElement(){ ReaderQuotas= new System.Xml.XmlDictionaryReaderQuotas {MaxDepth=2147483647, MaxStringContentLength=2147483647,  MaxArrayLength=2147483647, MaxBytesPerRead=2147483647}},new HttpTransportBindingElement()});bing.Name = "CustomBinding_DataService";EndpointAddress address = new EndpointAddress(http://www.xxx.com/MyService.svc);service = new MyServiceClient(bing, address);}catch (Exception ex){throw ex;}

The maximum string content length quota (8192) has been exceeded while reading XML data相关推荐

  1. [Bug]The maximum array length quota (16384) has been exceeded while reading XML data.

    写在前面 在项目中,有客户反应无法正常加载组织结构树,弄了一个测试的程序,在日志中查看到如下信息: Error in deserializing body of reply message for o ...

  2. String.length() 与 String.getBytes().length

    String.length() 返回字符串的字符个数,一个中文算一个字符: String.getBytes().length 返回字符串的字节长度,一个中文两个字节: String的getBytes( ...

  3. 数组的length属性和String的length()方法

    数组有length属性,没有length()方法,如: int[] a; a.lengh;   //返回a的长度. String只有length()方法,没有length属性,如: String s; ...

  4. string的length()和size()的区别?

    c++标准库中查看string的length()源码如下: size_type   __CLR_OR_THIS_CALL   length()   const     { //   return   ...

  5. Educoder–Java String类 length()方法与compareTo()方法的使用 - 花名册 substring()方法与indexOf()方法的使用 - 姓名查找编程要求

    文章目录 第1关:length()方法与compareTo()方法的使用 - 花名册 答案 第2关:substring()方法与indexOf()方法的使用 - 姓名查找编程要求 答案 第1关:len ...

  6. Spring cloud网关gateway代理websocket报Max frame length of 65536 has been exceeded

    Spring cloud网关gateway代理websocket报io.netty.handler.codec.http.websocketx.CorruptedWebSocketFrameExcep ...

  7. consider increasing the maximum size of the cache. After eviction approximately [9,230] KB of data

    业务场景 springboot项目,使用外置tomcat启动项目.在真实环境部署的时候,项目正常启动后提示 consider increasing the maximum size of the ca ...

  8. TypeError: ord() expected string of length 1, but int found

    错误如下 ord 里面要求的是一个string 的字符, 这里使用了int  ,所以修改了print(ord("1")) 转ASCII 的时候需要注意了,

  9. TypeError: ord() expected a character, but string of length 6 found

    错误如下 ord()  期待是一个字符,你使用了string 所以转ASCII 的时候需要注意了, 里面是字符 ,比如 ord("a")   , 修改下把

最新文章

  1. Java定时任务调度工具
  2. 20145201李子璇 《网络对抗》恶意代码分析
  3. 背水一战 Windows 10 (61) - 控件(媒体类): InkCanvas 涂鸦编辑
  4. SwiftUI之深入解析如何创建和组合视图
  5. ActiveMQ的自定义安全插件(十)
  6. c语言解析分隔符文本,c – 使用分隔符读取文件
  7. 错误的日志可能会导致疯狂;好日志可能会成为魔杖
  8. 解决log4j:WARN Error initializing output writer. log4j:WARN Unsupported encoding?的问题
  9. python list join函数_Python中join()函数多种操作代码实例
  10. html转换为jpg格式,JPG转换成HTML的两种方法
  11. adb 版本更新后执行依旧是旧版本解决方法
  12. 线性方程组求解——基于MTALAB/Octave,Numpy,Sympy和Maxima
  13. 智能(语音)对话系统架构研究
  14. 【Comet OJ - 2019国庆欢乐赛 F】 高速公路
  15. macOS根目录上无法写入文件和创建目录的问题
  16. Android自定义view之围棋动画
  17. Github 配置SSH key 下载项目并关联
  18. Java 中 Unicode 和 char 的关系
  19. 4p、4c、4R营销理论概要
  20. C语言 typedef重命名

热门文章

  1. go 定义一个结构体并赋初始值_Go中必须谈论的四个迷点
  2. c语言编写的程序停止运行程序,C语言中,编译成功但运行停止的几个原因
  3. 系统部署文档_惊喜!Alibaba架构师终于发布“微服务架构与实践”文档
  4. 常见JavaScript基础面试题上(附答案)
  5. 【新星计划】MATLAB绘制图形
  6. matlab simulink数据导出到变量区
  7. android ip地址扫描,Android:手机扫描局域网所有ip,并进行socket通讯
  8. android 自启动列表,Android 机型设置自启动的跳转界面
  9. 怎样在线把别人web前端代码抓下_自学web前端8个月,我是怎样拿下7K薪资的?
  10. python里的resize_Python玩转蔡徐坤