WCF服务接口多,客户端在引用时出错!报WCF The maximum nametable character count quota (16384) has been exceeded while reading XML data错误

在服务端中定义接口太多时,在客户端的服务引用时,报错误:

元数据包含无法解析的引用:“net.tcp://localhost:8081/BaseData/mex”。    XML 文档中有错误。    读取 XML 数据时,超出最大名称表字符计数配额 (16384)。名称表是用于存储在处理 XML 时所遇到的字符串的数据结构 - 具有非重复元素、属性名称和属性值的长 XML 文档可能会触发此配额。通过更改在创建 XML 读取器时所使用的 XmlDictionaryReaderQuotas 对象的  MaxNameTableCharCount 属性,可增加此配额。

解决方法:

服务端配置文件:

<system.serviceModel>
    <services>
      <!--基础数据服务-->
      <service name="PmsWcfServer.PmsWcfBaseData" behaviorConfiguration="WcfBaseData">
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://127.0.0.1:8081"/>
          </baseAddresses>
        </host>
        <endpoint address="" binding="netTcpBinding"  contract="PmsWcfServer.IPmsWcfBaseData" bindingConfiguration="BindBaseData"/>
        <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
 
    <behaviors>
      <serviceBehaviors>
        <behavior name="WcfBaseData">
          <serviceDebug includeExceptionDetailInFaults="true"/>
          <serviceMetadata httpGetEnabled="false"/>
          <serviceCredentials>
            <serviceCertificate x509FindType="FindBySubjectName" findValue="PmsWcfServer" storeLocation="LocalMachine"/>
            <userNameAuthentication userNamePasswordValidationMode="Custom"  customUserNamePasswordValidatorType="PmsWcfServer.CheckUserNamePass,PmsWcfServer"/>
          </serviceCredentials>
        </behavior>
      </serviceBehaviors>
      
      <endpointBehaviors>
        <behavior name="BindBaseData">
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
    
    <bindings>
      <netTcpBinding>
        <binding name="BindBaseData" maxReceivedMessageSize="2147483647">
          <security mode="Message">
            <message clientCredentialType="UserName"/>
          </security>

<!--注意:红色字体,这里必须要修改maxNameTableCharCount值,增大配额-->

          <readerQuotas maxNameTableCharCount="2147483647" maxStringContentLength="2147483647" maxBytesPerRead="2147483647" maxArrayLength="2147483647" maxDepth="32000"/>
        </binding>
      </netTcpBinding>
    </bindings>
  </system.serviceModel>

只是修改以上配置文件,客户端依然后引用不成功,还需要修改:C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe.Config文件,在文件后面增加以下节:

   <system.serviceModel>  
    <bindings>  
      <netTcpBinding>  
        <binding name="BindSystem" maxBufferPoolSize="2147483647"  
          maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">  
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"  
            maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />  
          <security mode="None" />  
        </binding>  
      </netTcpBinding>  
    </bindings>  
    <client>  
      <endpoint binding="netTcpBinding" bindingConfiguration="BindSystem"  
        contract="IMetadataExchange" name="net.tcp" />  
    </client>  

</system.serviceModel>

重启VS,后再次引用成功!

转自http://www.cnblogs.com/y740504/archive/2012/01/16/2323235.html

WCF服务接口多,客户端在引用时出错!报WCF The maximum nametable character count quota (16384) has been exceeded while reading XML data错误的更多相关文章

  1. WCF常见异常-The maximum string content length quota (8192) has been exceeded while reading XML data

    异常信息:The maximum string content length quota (8192) has been exceeded while reading XML data 问题:调用第三 ...

  2. C# 用SoapUI调试WCF服务接口(WCF中包含用户名密码的验证)

    问题描述: 一般调试wcf程序可以直接建一个单元测试,直接调接口. 但是,这次,我还要测试在接口内的代码中看接收到的用户名密码是否正确,所以,单一的直接调用接口方法行不通, 然后就想办法通过soapU ...

  3. 关于使用FusionCharts生成图表时出现invalid xml data错误提示的解决方法

    FusionCharts的确功能是够强大的.收集的功能估计更强大.在初次使用时,对着手册,一步一步操作,就是生成图表工具不成功.一直报"Invalid xml data"错误.后面 ...

  4. 一: WCF的服务端与客户端在通信时有三种模式:请求响应模式、数据报模式和双工通讯模式。

    说一下基本知识,  1.如果想要将当前接口作为wcf服务器,则一定要加上[ServiceContract] 契约 2.要想将方法作为wcf服务方法发布给外部调用,则一定要加上    [Operatio ...

  5. WCF服务在类库中的引用

    在类库中引用了WCF服务,悲剧降临了,追踪日志看到下边一串: --------------------------------------------------------------------- ...

  6. 搭建基于asp.net的wcf服务,ios客户端调用的实现记录

    一.写wcf 问题: 1.特定的格式 2.数据绑定 3.加密解密 二.发布到iis 问题: 1.访问权限问题,添加everyone权限 访问网站时:http://localhost/WebbUploa ...

  7. WCF服务端与客户端时间匹配问题

    当服务端部署的WCF服务服务在被客户机调用时,如果显示: 错误,展开后,详细错误为:An error occurred when verifying security for the message ...

  8. 保持WCF服务端与客户端的长连接

    背景 客户端与服务端使用WCF建立连接后:1.可能长时间不对话(调用服务操作):2.客户端的网络不稳定. 为服务端与客户端两边都写“心跳检测”代码?不愿意. 解决 设置inactivityTimeou ...

  9. wcf使用JetEntityFrameworkProvider.dll写access数据库时,报"操作必须使用一个可更新的查询"错误的解决办法

    由于users用户组无权重写access数据库,需要设置users组用户能读写access数据库.

随机推荐

  1. BZOJ 1083 题解

    1083: [SCOI2005]繁忙的都市 Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 2431  Solved: 1596[Submit][Sta ...

  2. 【BZOJ2223/3524】[Coci 2009]PATULJCI

    Description Input   Output 10 3 1 2 1 2 1 2 3 2 3 3 8 1 2 1 3 1 4 1 5 2 5 2 6 6 9 7 10 Sample Input ...

  3. iOS Xcode7免证书真机调试

    在Xcode 7 正式发布的日子里,苹果再次给开发者带来了惊喜,从此以后只要是真机调试的时候,不再需要花99刀去购买开发者证书,但是如果APP需要上架依旧还是需要购买开发者证书的.这个惊喜对正在学习i ...

  4. C++ substr() 和 Java substring() 区别

    Java和C++中都有关于子字符串的操作,C++中是substr(),Java中是substring(),两者的用法上稍有些区别,首先针对只有一个参数的情况: s.substr(start) 和 s. ...

  5. linux中,常用的账号管理命令

    创建新用户:adduser 用户名创建新用户并将其加入一个现有组中:adduser 用户名 -G 组名创建新用户并使其只属于该组:adduser 用户名 -g 组名创建用户密码:passwd 用户名创 ...

  6. HDU1443 模拟(难)

    Joseph Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Subm ...

  7. .net 文件下载【转】

    方式一:TransmitFile实现下载.将指定的文件直接写入 HTTP 响应输出流,而不在内存中缓冲该文件.     protected void Button1_Click(object send ...

  8. 用Webshell直接杀入内网

    有时候要代理进内网,但是服务器没有外网端口,也没法执行命令反弹lcx什么的,也没有提权什么什么的,只有一个webshell,这个时候就比较蛋疼了. 鄙人不才,写了一个比较山寨的php+nginx反向代 ...

  9. 了解C++默认编写并调用哪些函数

    概念:编译器可以暗自为class创建default构造函数.copy构造函数.copy assignmengt构造函数,以及析构函数. 比如你写下:struct Node { }; 这就好像你写下这样 ...

  10. Mac 系统下cocos2dx 环境变量设置

    Mac 系统环境变量设置   vim ~/.bash_profile    export PATH=$PATH:/Users/wangchengcheng/Downloads/LearningSoft ...