WCF格式化程序尝试对消息反序列化时引发异常

RUNBEAR 2012-08-02 01:19:49
查了资料说是config文件的问题。

content的长度在60000左右。以前没咋弄过WCF。。。是什么问题。。。
proxy.Submit(content);


格式化程序尝试对消息反序列化时引发异常: 对操作“Submit”的请求消息正文进行反序列化时出现错误。读取 XML 数据时,超出最大字符串内容长度配额 (8192)。通过更改在创建 XML 读取器时所使用的 XmlDictionaryReaderQuotas 对象的 MaxStringContentLength 属性,可增加此配额。 行 1,位置 15495。


客户端配置:

<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ISchedule" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="2097152" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:9097/Schedule.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_ISchedule" contract="ServiceReference1.ISchedule"
name="BasicHttpBinding_ISchedule" />
</client>
</system.serviceModel>


服务端配置:

<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_USService1" maxBufferPoolSize="21474835647" maxReceivedMessageSize="2147483647" >
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
<security mode="None">
<transport clientCredentialType="None"/>
<message clientCredentialType="UserName"/>
</security>
</binding>
</basicHttpBinding>
</bindings>

<behaviors>
<serviceBehaviors>
<behavior name="Web.WCF.ShareServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>

<services>
<service behaviorConfiguration="Web.WCF.ShareServiceBehavior" name="Web.WCF.ShareService">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_USService1" contract="ServiceReference1.ISchedule"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>

<serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
...全文
599 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
RUNBEAR 2012-08-02
  • 打赏
  • 举报
回复
知道是怎么回事了。。。没配置 endpoint。 嚓
宝_爸 2012-08-02
  • 打赏
  • 举报
回复
从错误看 最大字符串内容长度配额 是(8192)


我觉得客户端的这些也得改

maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"

可以在服务器端参考下面的配置

http://dotnettrails.wordpress.com/2009/11/09/wcf-maximum-string-length-quota-8192-has-been-exceeded/

然后试一试在客户端Update service reference...,会把配置同步到客户端
RUNBEAR 2012-08-02
  • 打赏
  • 举报
回复
是部署在II7。 应用程序池是: .net 4.0经典模式。
我把字符串长度控制在8192以内,执行是没有问题。。 但我看了全部的config文件,maxStringContentLength我都改了。。

62,041

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧