如题,查询一个数据集,
存储过程返回如:select * from B
中间层定义 public DataSet GetTable(string 查询条件);
客户端定义 DataSet ds = wcfClient.GetTable("")
以前一直正常着,查询也很快速,这两天不知修改到哪了,所有的查询如果返回记录较大时(100条左右),客户端就会出现服务端返回的异常错误“创建MTOM消息读取器时出错”
客户端 app.config 配置如下
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IWS_JXC" openTimeout="00:10:00"
receiveTimeout="00:20:00" sendTimeout="00:10:00" maxBufferPoolSize="999999999"
maxReceivedMessageSize="999999999" messageEncoding="Mtom" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://127.0.0.1/JXC_AT/Service/WS_JXC.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IWS_JXC"
contract="Ref_WS_JXC.IWS_JXC" name="BasicHttpBinding_IWS_JXC" />
</client>
<behaviors>
<endpointBehaviors>
<behavior name="SerializerBehaviour">
<dataContractSerializer maxItemsInObjectGraph="999999999" />
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
测试了很多次,终于发现了问题啊!原来是生成的basicHttpBinding配置不正确所致,实现上也不是不正确,只是配置中少了"maxBufferSize="999999999""这一段所致。而且,VS2012还有一个小BUG,就是有时重新生成WCF服务的引用时,这个配置通常会重置,导致这个配置项丢了,请大家一定要注意哟!
<binding name="BasicHttpBinding_IWS_JXC" closeTimeout="00:10:00"
openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
maxBufferPoolSize="999999999" maxReceivedMessageSize="999999999"
maxBufferSize="999999999"
messageEncoding="Mtom" />
解决WCF调用时出现错误:“创建MTOM消息读取器时出错”