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
问题场景:在我们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=,
MaxStringContentLength=,
MaxArrayLength=,
MaxBytesPerRead=}},
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的更多相关文章
- 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 问题:调用第三 ...
- 调用WebServiceWebService提示The maximum string content length quota (8192) has been exceeded while reading XML data的解决办法
在web.config中,bindings节点下,对应的服务名称中,原本可能是自动折叠的“/>”,需要改成手动折叠的</binding>,然后在中间加上<readerQuota ...
- [Bug]The maximum array length quota (16384) has been exceeded while reading XML data.
写在前面 在项目中,有客户反应无法正常加载组织结构树,弄了一个测试的程序,在日志中查看到如下信息: Error in deserializing body of reply message for o ...
- 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 ...
- String Matching Content Length
hihocoder #1059 :String Matching Content Length 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 We define the ...
- ics httpDELETE 时增加 content,length 特别需求
unit: OverbyteIcsHttpProt.pasprocedure THttpCli.SendRequest(const Method, Version: String); var Head ...
- String.length()和String.getBytes().length
1.字符与字节 抛出如下代码: public static void main(String[] args) { String str = "活出自己范儿"; System.out ...
- 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 ...
- 定时器setInterval, innerText获取文本, charAt()获取单个字符串, substring(1, content.length)获取范围内的字符串, 实现字符串的滚动效果
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
随机推荐
- 将ACCESS数据库迁移到SQLSERVER数据库
原文:将ACCESS数据库迁移到SQLSERVER数据库 将ACCESS数据库迁移到SQLSERVER数据库 ACCESS2000文件 用ACCESS2007打开,并迁移到SQLSERVER2005里 ...
- 用数据说话,外贸产品选择(中篇)-google趋势分析法
在上篇文章<用数据说话,贸B2C产品选择(上篇)-热门搜索法>中我们能搜索出来几种产品了,那我们就拿上次搜索出来的热门产品来做一个趋势分析.我们经过几个站点挑出了几种热卖产品Wedding ...
- CSDN挑战编程——《金色十月线上编程比赛第二题:解密》
金色十月线上编程比赛第二题:解密 题目详情: 小强是一名学生, 同一时候他也是一个黑客. 考试结束后不久.他吃惊的发现自己的高等数学科目竟然挂了,于是他果断入侵了学校教务部站点. 在入侵的过程中.他发 ...
- network: Android 网络推断(wifi、3G与其它)
public class NetworkProber { /** * 网络是否可用 * * @param activity * @return */ public static bool ...
- 使用 WPF 实现所见即所得HTML编辑器
Introduction In this tip, you will learn the use of WPF webbrowser control and the use of the librar ...
- Android 随着输入框控件的清除功能ClearEditText,抄IOS输入框
今天给大家带来一个非常有用的小控件ClearEditText,就是在Android系统的输入框右边增加一个小图标,点击小图标能够清除输入框里面的内容,IOS上面直接设置某个属性就能够实现这一功能.可是 ...
- poj 3311Hie with the Pie
题意:一个送披萨的,每次送外卖不超过10个地方,给你这些地方之间的时间,求送完外卖回到店里的总时间最小. 解法一: 这个n不大,即使是NP问题也才1E6多一些所以可以dfs():具体的回溯方法结合da ...
- C#取硬盘、CPU、主板、网卡的序号 ManagementObjectSearcher
原文:C#取硬盘.CPU.主板.网卡的序号 ManagementObjectSearcher private void button1_Click(object sender, EventArgs e ...
- hdu 4661 Message Passing(木DP&组合数学)
Message Passing Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Other ...
- sql pivot、unpivot和partition by用法
原文:sql pivot.unpivot和partition by用法 演示脚本 from sys.sysobjects where name = 'Student' AND type = 'U') ...