原文: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.在客户端或服务器的做如下配置:

  1. <binding name="xxx" maxReceivedMessageSize="2147483647">
  2.  
  3. <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647"
  4.  
  5. maxNameTableCharCount="2147483647" />
  6.  
  7. security>
  8.  
  9. </binding>

代码中可修改如下:

  1. MyServiceClient service = null;
  2. //MyServiceClient service = new MyServiceClient();
  3. try
  4. {
  5.  
  6. System.ServiceModel.Channels.CustomBinding bing = new System.ServiceModel.Channels.CustomBinding(
  7. new System.ServiceModel.Channels.BindingElement[]{
  8. new BinaryMessageEncodingBindingElement(){ ReaderQuotas= new System.Xml.XmlDictionaryReaderQuotas {
  9. MaxDepth=,
  10. MaxStringContentLength=,
  11. MaxArrayLength=,
  12. MaxBytesPerRead=}},
  13. new HttpTransportBindingElement()
  14. });
  15.  
  16. bing.Name = "CustomBinding_DataService";
  17. EndpointAddress address = new EndpointAddress(http://www.xxx.com/MyService.svc);
  18.  
  19. service = new MyServiceClient(bing, address);
  20.  
  21. }
  22. catch (Exception ex)
  23. {
  24. throw ex;
  25. }

The maximum string content length quota (8192) has been exceeded while reading XML data的更多相关文章

  1. WCF常见异常-The maximum string content length quota (8192) has been exceeded while reading XML data

    异常信息:The maximum string content length quota (8192) has been exceeded while reading XML data 问题:调用第三 ...

  2. 调用WebServiceWebService提示The maximum string content length quota (8192) has been exceeded while reading XML data的解决办法

    在web.config中,bindings节点下,对应的服务名称中,原本可能是自动折叠的“/>”,需要改成手动折叠的</binding>,然后在中间加上<readerQuota ...

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

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

  4. WCF服务接口多,客户端在引用时出错!报WCF The maximum nametable character count quota (16384) has been exceeded while reading XML data错误

    WCF服务接口多,客户端在引用时出错!报WCF The maximum nametable character count quota (16384) has been exceeded while ...

  5. String Matching Content Length

    hihocoder #1059 :String Matching Content Length 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 We define the ...

  6. ics httpDELETE 时增加 content,length 特别需求

    unit: OverbyteIcsHttpProt.pasprocedure THttpCli.SendRequest(const Method, Version: String); var Head ...

  7. String.length()和String.getBytes().length

    1.字符与字节 抛出如下代码: public static void main(String[] args) { String str = "活出自己范儿"; System.out ...

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

    源代码是这样: s=b'^SdVkT#S ]`Y\\!^)\x8f\x80ism' key='' for i in s:     i=ord(i)-16     key+=chr(i^32) prin ...

  9. 定时器setInterval, innerText获取文本, charAt()获取单个字符串, substring(1, content.length)获取范围内的字符串, 实现字符串的滚动效果

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

随机推荐

  1. 数据市中心全省中国mysql脚本

    1.查尔斯省 watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvd2h6aGFvY2hhbw==/font/5a6L5L2T/fontsize/400/fill ...

  2. 重新想象 Windows 8 Store Apps (1) - 控件之文本控件: TextBlock, TextBox, PasswordBox, RichEditBox, RichTextBlock, RichTextBlockOverflow

    原文:重新想象 Windows 8 Store Apps (1) - 控件之文本控件: TextBlock, TextBox, PasswordBox, RichEditBox, RichTextBl ...

  3. 如何利用多核CPU来加速你的Linux命令 — awk, sed, bzip2, grep, wc等(转)

    你是否曾经有过要计算一个非常大的数据(几百GB)的需求?或在里面搜索,或其它操作——一些无法并行的操作.数据专家们,我是在对你们说.你可能有一个4核或更多核的CPU,但我们合适的工具,例如 grep, ...

  4. 全文检索引擎Solr 指南

    全文检索引擎Solr系列:第一篇:http://t.cn/RP004gl.第二篇:http://t.cn/RPHDjk7 .第三篇:http://t.cn/RPuJt3T

  5. 制作简易计算器处理过程Servlet

    CalculationServlet.java: package com.you.servlet; import java.io.IOException; import java.io.PrintWr ...

  6. Pagination jquery ajax 分页参考资料

    http://www.zhangxinxu.com/wordpress/2010/01/jquery-pagination-ajax%E5%88%86%E9%A1%B5%E6%8F%92%E4%BB% ...

  7. [LeetCode235]Lowest Common Ancestor of a Binary Search Tree

    题目: Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in th ...

  8. SRM 620 D2L3: RandomGraph, dp

    称号:http://community.topcoder.com/stat? c=problem_statement&pm=13143&rd=15853 參考:http://apps. ...

  9. Poj3414广泛搜索

    <span style="color:#330099;">/* D - D Time Limit:1000MS Memory Limit:65536KB 64bit I ...

  10. 【转】linux建立软链接

    实例:ln -s /home/gamestat    /gamestat linux下的软链接类似于windows下的快捷方式 ln -s a b 中的 a 就是源文件,b是链接文件名,其作用是当进入 ...