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

aier3333 2014-04-14 09:18:37
写了个WCF服务提供了查询接口,在WIN7下,客户端调用正常,可在win2003下,只要返回的数据稍微大一点,就会抛以下异常:# InsertNewsByDB[格式化程序尝试对消息反序列化时引发异常: 尝试对参数 http://tempuri.org/ 进行反序列化时出错: GetNewsResult。InnerException 消息是“反序列化对象 属于类型 Muchinfo.News.Data.News[] 时出现错误。读取 XML 数据时,超出最大字符串内容长度配额 (8192)。通过更改在创建 XML 读取器时所使用的 XmlDictionaryReaderQuotas 对象的 MaxStringContentLength 属性,可增加此配额。”。有关详细信息,请参见 InnerException。]。

WCF提供的契约如下:

[OperationContract]
[WebGet]
News[] GetNews(DateTime mdate);

服务端配置文件如下:

<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<!-- 服务集合 -->
<services>
<service behaviorConfiguration="ssBehavior" name="Muchinfo.News.NewsSelectService">
<!--<endpoint address="" behaviorConfiguration="epBehavior"
binding="webHttpBinding" bindingConfiguration="nonSecurityHttp"
contract="Muchinfo.News.SelectContract.INewsSelectService" />-->
<endpoint address="net.tcp://0.0.0.0:8080" behaviorConfiguration="maxSerializeBehavior"
binding="customBinding" bindingConfiguration="compactBinding"
contract="Muchinfo.News.SelectContract.INewsSelectService" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://0.0.0.0:8080/NewsSelectService" />
</baseAddresses>
</host>
</service>

</services>
<!-- 绑定 -->
<bindings>
<netTcpBinding>
<binding name="compactBinding" transferMode="Streamed" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="2147483647" maxNameTableCharCount="16384"/>
<security mode="None"></security>
</binding>
</netTcpBinding>
<customBinding>
<binding name="nsWebHttpBinding">
<httpTransport maxBufferPoolSize="6553600" maxReceivedMessageSize="6553600" allowCookies="false" authenticationScheme="Anonymous" maxBufferSize="6553600" />
<webMessageEncoding writeEncoding="utf-8" />
</binding>
<binding name="compactBinding">
<compactMessageEncoding>
<binaryMessageEncoding />
</compactMessageEncoding>
<tcpTransport maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxPendingConnections="20" maxPendingAccepts="2" listenBacklog="20">
<connectionPoolSettings maxOutboundConnectionsPerEndpoint="20" />
</tcpTransport>
</binding>
<binding name="compact2Binding">
<compactMessageEncoding>
<textMessageEncoding />
</compactMessageEncoding>
<httpTransport maxBufferPoolSize="6553600" maxReceivedMessageSize="6553600" allowCookies="false" authenticationScheme="Anonymous" maxBufferSize="6553600" />
</binding>
</customBinding>
<webHttpBinding>
<binding name="nonSecurityHttp" allowCookies="false" maxBufferPoolSize="4194304" maxReceivedMessageSize="4194304" writeEncoding="utf-8">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="32767" maxNameTableCharCount="6553600" />
<security mode="None" />
</binding>
</webHttpBinding>
</bindings>
<!-- 行为 -->
<behaviors>
<endpointBehaviors>
<behavior name="maxSerializeBehavior">
<dataContractSerializer ignoreExtensionDataObject="true" maxItemsInObjectGraph="2147483647" />
</behavior>
<behavior name="epBehavior">
<!--<enableWebScript/>-->
<dataContractSerializer ignoreExtensionDataObject="true" maxItemsInObjectGraph="2147483647" />
<webHttp helpEnabled="true" automaticFormatSelectionEnabled="false" defaultOutgoingResponseFormat="Json" />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="ssBehavior">
<serviceThrottling maxConcurrentCalls="500" maxConcurrentSessions="500" maxConcurrentInstances="5" />
<!--<serviceMetadata httpGetEnabled="true" httpGetUrl="MEX"/>-->
<serviceTimeouts transactionTimeout="00:05:00" />
<serviceDebug includeExceptionDetailInFaults="false" />
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>


客户端配置如下:

<system.serviceModel>

<bindings>
<customBinding>
<binding name="compactBinding">
<compactMessageEncoding>
<binaryMessageEncoding/>
</compactMessageEncoding>
<tcpTransport maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxPendingConnections="20" maxPendingAccepts="2" listenBacklog="20">
<connectionPoolSettings maxOutboundConnectionsPerEndpoint="20"/>
</tcpTransport>
</binding>
</customBinding>
<wsHttpBinding>
<binding name="nonSecurityHttp" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" useDefaultWebProxy="true" allowCookies="false">
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"/>
</security>
</binding>
<binding name="HstoryServices" closeTimeout="00:05:00" openTimeout="00:05:00" receiveTimeout="00:10:00" sendTimeout="00:05:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="true"/>
<security mode="None">
<transport clientCredentialType="Windows" proxyCredentialType="None" realm=""/>
<message clientCredentialType="Windows" negotiateServiceCredential="false"/>
</security>

</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="Behaviors.EndpointBehaviors">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors>
<client>
<!--@20130902 -->
<endpoint address="net.tcp://127.0.0.1:8080" binding="customBinding" name="SelectNews"
bindingConfiguration="compactBinding" contract="Muchinfo.News.SelectContract.INewsSelectService"
behaviorConfiguration="Behaviors.EndpointBehaviors"/>
</client>
</system.serviceModel>



请各位指点一下!!!!谢谢!!!!只有这么多分了。。。。。
...全文
164 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
aier3333 2014-04-14
  • 打赏
  • 举报
回复
aier3333 2014-04-14
  • 打赏
  • 举报
回复
没有人帮我吗?
aier3333 2014-04-14
  • 打赏
  • 举报
回复
补充一下,最坑的是,我开发环境下是正常的,无论返回多少数据。。我的开发环境WINSERFVER2008是正常的。

62,072

社区成员

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

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

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

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