调用WCF接口异常信息如下:
格式化程序尝试对消息反序列化时引发异常: 尝试对参数 http://tempuri.org/ 进行反序列化时出错: request。InnerException 消息是“反序列化对象 属于类型 TenantPlatform.WCF.DataContracts.EditSpecialTaskRequest 时出现错误。读取 XML 数据时,超出最大字符串内容长度配额 (8192)。通过更改在创建 XML 读取器时所使用的 XmlDictionaryReaderQuotas 对象的 MaxStringContentLength 属性,可增加此配额。”。有关详细信息,请参见 InnerException。”。有关详细信息,请参见服务器日志。
web.config文件配置如下:
<bindings>
<webHttpBinding>
<binding name="HttpBinding" maxReceivedMessageSize="2097152">
<readerQuotas maxDepth="32" maxStringContentLength="2097152" maxArrayLength="2097152" maxBytesPerRead="2097152" maxNameTableCharCount="2097152" />
<security mode="None"></security>
</binding>
</webHttpBinding>
</bindings>
<service behaviorConfiguration="*" name="*">
<endpoint address="" behaviorConfiguration="httpBehavior" binding="webHttpBinding" bindingConfiguration="HttpBinding"
contract="*" kind="webHttpEndpoint">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
最重要的一点是,需要添加 bindingConfiguration="HttpBinding" “HttpBinding”为 binding节点中的 name属性值。