WCF 客户端解决大数据量传输配置

1. 服务端返回数据给客户端报错

  在客户端配置文件中,主要是配置maxReceivedMessageSize

<system.serviceModel>
    <bindings>
      <basicHttpBinding>

<binding name="ServiceProxyBinding" closeTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"> <readerQuotas maxStringContentLength="134217728" /> </binding>

</basicHttpBinding> </bindings> <client> <endpoint address="http://localhost:8733/Test/Test.svc" binding="basicHttpBinding" bindingConfiguration="ServiceProxyBinding" contract="UniCloud.ServiceContracts.IPartService" name="IPartService" /> </client> </system.serviceModel>

2. 客户端传数据给服务端报错

  修改服务端web.config,主要也是配置maxReceivedMessageSize

<system.serviceModel>
<bindings> <basicHttpBinding>
<!--不写name,表示应用所有 basicHttpBinding-->
<binding closeTimeout="00:10:00" receiveTimeout="00:20:00" sendTimeout="00:20:00" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"> </binding> </basicHttpBinding> </bindings>

<behaviors> <serviceBehaviors> <behavior > <!-- 为避免泄漏元数据信息,请在部署前将以下值设置为 false --> <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" /> <!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息 --> <serviceDebug includeExceptionDetailInFaults="true" /> <dataContractSerializer maxItemsInObjectGraph="2147483647"/> </behavior> </serviceBehaviors> </behaviors> </system.serviceModel>

要修改所有的服务,不管是服务端还是客户端,Binding那边增加一个没有设置名字的默认配置就OK了

 参考文章:http://www.cnblogs.com/Gyoung/p/3369316.html

posted @ 2014-06-30 10:40  b̶i̶n̶g̶.̶  阅读(320)  评论(0编辑  收藏  举报