我收到以下错误:
格式化程序在试图反序列化消息时抛出一个异常:反序列化操作“InsertQuery”的请求消息正文中的错误。读取XML数据时已超出最大字符串内容长度配额(8192)。可以通过更改在创建XML读取器时使用的MaxStringContentLength对象上的XmlDictionaryReaderQuotas属性来增加此配额。第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>即使这样,我也会犯同样的错误:
请告诉我,为了解决这个问题,我需要做些什么改变。提前谢谢!!
发布于 2013-09-17 21:38:49
您是Web.config文件,表示您使用的是.NET 4.0,并且Web.config中没有显式定义的端点,因此WCF将为您提供一个默认端点(基于*.svc文件的位置),并为http方案使用basicHttpBinding的默认绑定。maxStringContentLength的默认值是8192。
要改变这种情况,您要么需要:
name属性)分配给端点的bindingConfiguration属性,或name属性,使您在配置文件中定义的绑定配置成为该类型绑定的默认配置,并将http的默认映射从basicHttpBinding更改为webHttpBinding。若要通过显式端点执行此操作,请将以下内容添加到Web.config文件中的<system.serviceModel>下
<services>
<service name="your service name">
<endpoint address="" binding="webHttpBinding"
bindingConfiguration="webHttpBindingDev"
contract="your fully-qualified contract name" />
</service>
</services>您必须为您的服务名称和合同提供适当的值。
要通过设置默认值来完成此操作,需要删除webHttpBinding属性,将指定的webHttpBinding绑定配置标记为默认值:
<bindings>
<webHttpBinding>
<binding>
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</binding>
</webHttpBinding>
</bindings>接下来,需要将webHttpBinding设置为http方案的默认绑定:
<protocolMapping>
<add binding="webHttpBinding" scheme="http" />
</protocolMapping>使用这两个更改,您将不需要添加显式端点。
此外,由于您使用的是webHttpBinding,所以我认为需要将以下内容添加到端点行为中:
<behaviors>
<endpointBehaviors>
<behavior>
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>有关WCF 4中默认端点、绑定等的更多信息,请查看开发人员介绍Windows通信基金会4。
https://stackoverflow.com/questions/18849341
复制相似问题