【发布时间】:2013-09-21 20:40:47
【问题描述】:
我收到以下错误:
格式化程序在尝试反序列化消息时抛出异常:反序列化操作“InsertQuery”的请求消息正文时出错。读取 XML 数据时已超出最大字符串内容长度配额 (8192)。可以通过更改创建 XML 阅读器时使用的 XmlDictionaryReaderQuotas 对象的 MaxStringContentLength 属性来增加此配额。第 1 行,位置 33788。
为了增加 MaxStringContentLength 的大小,我修改了我的 Web.config,如下所示..
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<webHttpBinding>
<binding name="webHttpBindingDev">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</webHttpBinding>
</bindings>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
即使这样我也得到了同样的错误:(
请告诉我需要对我进行哪些更改才能解决此问题。 提前致谢!!
【问题讨论】:
-
在服务行为中,添加:
-
嗨 Icryder,我添加了 ataContractSerializer 如下,即使这样我也得到了同样的错误:
-
您永远不会将绑定分配给端点。定义一个端点并使用
bindingConfigurationattribute,或者(如果您在.NET 4.0+ 中)从绑定中删除name属性(使其成为默认值)并确保http映射到@ 987654325@ 在您的 web.config 的协议部分(否则我怀疑您将使用basicHttpBinding)。
标签: .net wcf web-services wcf-data-services wcf-binding