【发布时间】:2011-09-23 16:07:29
【问题描述】:
我在服务上做了所有正确的设置,但是当我尝试将大量 JSON 数据放入我的 WCF REST 服务时,仍然得到同样愚蠢的 400 错误请求。下面是我的服务 Web.config。我已经为此苦苦挣扎了 3 周,但没有找到答案。这是响应中的异常详细信息:
“反序列化时出错 BuildStepResource 类型的对象。这 最大字符串内容长度配额 (8192) 读取时已超出 XML 数据。此配额可能会增加 通过更改 MaxStringContentLength 财产在 使用的 XmlDictionaryReaderQuotas 对象 创建 XML 阅读器时。”
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
<bindings>
<webHttpBinding>
<binding name="nonSSLBinding" maxReceivedMessageSize="4194304" receiveTimeout="01:00:00" sendTimeout="01:00:00" >
<security mode="None">
<transport clientCredentialType="Ntlm"/>
</security>
<readerQuotas maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxDepth="2147483647" maxNameTableCharCount="2147483647" maxStringContentLength="2147483647"/>
</binding>
<binding name="sslBinding" maxReceivedMessageSize="4194304" receiveTimeout="01:00:00" sendTimeout="01:00:00" >
<security mode="Transport">
<transport clientCredentialType="Basic"/>
</security>
<readerQuotas maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxDepth="2147483647" maxNameTableCharCount="2147483647" maxStringContentLength="2147483647"/>
</binding>
</webHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="webBehavior" name="serviceEndpoints">
<endpoint address="" binding="webHttpBinding" contract="ISWCRestService" bindingConfiguration="nonSSLBinding" behaviorConfiguration="customBehavior"/>
<endpoint address="" binding="webHttpBinding" contract="ISWCRestService" bindingConfiguration="sslBinding" behaviorConfiguration="customBehavior"/>
<endpoint address="" binding="webHttpBinding" contract="IXmlEndpoint" bindingConfiguration="nonSSLBinding" behaviorConfiguration="customBehavior"/>
<endpoint address="" binding="webHttpBinding" contract="IXmlEndpoint" bindingConfiguration="sslBinding" behaviorConfiguration="customBehavior"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="webBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<dataContractSerializer maxItemsInObjectGraph="2147483646" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="customBehavior">
<webHttp automaticFormatSelectionEnabled="false" helpEnabled="true"/>
<dataContractSerializer maxItemsInObjectGraph="2147483646" />
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
【问题讨论】:
-
你解决过这个问题吗?我也遇到过类似的问题。
标签: wcf