c#WCF最大字符串内容长度配额
本文关键字:字符串 c#WCF | 更新日期: 2023-09-27 18:27:40
我知道这已经发布了几次了,但我开始抓狂了。。。我得到以下错误:
格式化程序在尝试反序列化消息时引发异常:反序列化操作"CreateEmailEntry"的请求消息正文时出错。读取XML数据时超过了最大字符串内容长度配额(8192)。可以通过更改创建XML读取器时使用的XmlDictionaryReaderQuotas对象的MaxStringContentLength属性来增加此配额。157号线,位置92。
以下是端点配置:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IAddEmail" maxReceivedMessageSize="65536">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost/AutoSearchEmail/AddEmail.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IAddEmail"
contract="ServiceReference1.IAddEmail" name="BasicHttpBinding_IAddEmail" />
</client>
</system.serviceModel>
以下是WCF项目的配置:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IAddEmail" maxReceivedMessageSize="65536">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
我读过很多帖子,上面写着"增加maxStringContentLength",我相信我已经读过了,但很可能是我忽略了。。。
我真的不喜欢在代码中创建端点的想法——只是听起来像是另一层出错的东西!
提前谢谢。
对于服务配置,这是你的整个配置吗,因为我缺少
<services>
将绑定应用于服务的部分。