zoukankan      html  css  js  c++  java
  • WCF中如何修改MaxItemsInObjectGraph的限制 武胜

    在WCF/WebService中,如果返回值过大,比如Array,List,DataSet等达到一定数量级的话,可能引发下面的异常

    1. 受信Message Quota Size超过65536 (System.ServiceModel.CommunicationException)

    解决方法:修改客户端配置文件app.configmaxReceivedMessageSize,maxBufferSize 两个属性。

    但是,数量级继续增大,还会遇到新的问题:

    2. MaxItemsInObjectGraph Quta Size超过65536(InnerException:System.Runtime.SerializationException)

    生成XML如下,其中红色部分是被修改的部分:
    <behavior name="NewBehavior"> 
        <dataContractSerializer maxItemsInObjectGraph="65536000" /> 
    </behavior

    ...

    <endpoint address="http://localhost:3511/Service1.asmx" behaviorConfiguration="NewBehavior
                    binding="basicHttpBinding" bindingConfiguration="Service1Soap" 
                    contract="WebSvc.Service1Soap" name="Service1Soap" />

    1. <?xml version="1.0" encoding="utf-8" ?>   
    2. <configuration>   
    3.     <system.serviceModel>   
    4.         <behaviors>   
    5.             <endpointBehaviors>   
    6.                 <behavior name="NewBehavior">   
    7.                     <dataContractSerializer maxItemsInObjectGraph="65536000" />   
    8.                 </behavior>   
    9.             </endpointBehaviors>   
    10.         </behaviors>   
    11.         <bindings>   
    12.             <basicHttpBinding>   
    13.                 <binding name="Service1Soap" closeTimeout="00:01:00" openTimeout="00:01:00"   
    14.                     receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"   
    15.                     bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"   
    16.                     maxBufferSize="65536000" maxBufferPoolSize="524288" maxReceivedMessageSize="65536000"   
    17.                     messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"   
    18.                     useDefaultWebProxy="true">   
    19.                     <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"   
    20.                         maxBytesPerRead="4096" maxNameTableCharCount="16384" />   
    21.                     <security mode="None">   
    22.                         <transport clientCredentialType="None" proxyCredentialType="None"   
    23.                             realm="" />   
    24.                         <message clientCredentialType="UserName" algorithmSuite="Default" />   
    25.                     </security>   
    26.                 </binding>   
    27.             </basicHttpBinding>   
    28.         </bindings>   
    29.         <client>   
    30.             <endpoint address="http://localhost:3511/Service1.asmx" behaviorConfiguration="NewBehavior"   
    31.                 binding="basicHttpBinding" bindingConfiguration="Service1Soap"   
    32.                 contract="WebSvc.Service1Soap" name="Service1Soap" />   
    33.         </client>   
    34.     </system.serviceModel>   
    35. </configuration> 
  • 相关阅读:
    ExtJs之表格控件入门
    bootstrap错误警告信息提示
    android采用MVP漫画APP、适配刘海屏、小黄车主界面、录音波浪动画、综合APP等源码
    iOS仿QQ侧滑菜单、登录按钮动画、仿斗鱼直播APP、城市选择器、自动布局等源码
    iOS仿抖音节拍界面、Swift,MVVM架构完整项目、日历demo、滚动切换分类等源码
    接住! 安卓巴士开发者大会花絮第二弹来啦
    iOS漂亮的Toolbar动画、仿美团主页、简易笔记本、流失布局、标签分组等源码
    android仿今日头条App、多种漂亮加载效果、选择器汇总、记事本App、Kotlin开发等源码
    到场率高达96% 这才是高水准技术大会应该有的样子
    iOS动画效果集合、 通过摄像头获取心率、仿淘宝滑动样式、瀑布流、分类切换布局等源码
  • 原文地址:https://www.cnblogs.com/zeroone/p/2454790.html
Copyright © 2011-2022 走看看