使用WCF服務的客戶端出現maxReceivedMessageSize異常


使用WCF服務的客戶端出現maxReceivedMessageSize異常解決方案

    當使用WCF的客戶端調取的數據過多時,會出現這個異常。一般情況下,系統默認值是65536,大約容納100-200條左右的數據。所以建議您在您的項目中,為了避免使用時時期出現這個錯誤。您應該使用如下解決方案。

 

    解決方案:在客戶端的Config文件中,加入maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"屬性。

如圖:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_ICaseService"  maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"/>
        <binding name="BasicHttpBinding_IEvidenceService"   maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"/>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:8537/Service/CaseService.svc"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ICaseService"
        contract="CaseService.ICaseService" name="BasicHttpBinding_ICaseService" />
      <endpoint address="http://localhost:8537/Service/EvidenceService.svc"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IEvidenceService"
        contract="EvidenceService.IEvidenceService" name="BasicHttpBinding_IEvidenceService" />
</client> </system.serviceModel> </configuration>

 

再次運行,一切正常。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM