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】3670: [Noi2014]动物园

    http://www.lydsy.com/JudgeOnline/problem.php?id=3670 题意:太水了= = #include <bits/stdc++.h> using ...

  2. 【BZOJ】3456: 城市规划

    http://www.lydsy.com/JudgeOnline/problem.php?id=3456 题意:求n个点的无向连通图的方案.(n<=130000) #include <bi ...

  3. 'Could not load NIB in bundle: 'NSBundle xxx/storeFlix.app> ' with name 'UIViewController-w6Q-ra-j06' and directory 'StoreFlixIpad.storyboardc

    1.此代码是从 git clone xxx 下载的. 2.使用 sourcetree 下载即可解决此问题.

  4. mysql 表字段不能使用type???

    type 字段 可能跟系统内置字段有冲突吧

  5. java中instanceof和getClass()的区别分析

    class A { } class B extends A { } Object o1 = new A();  Object o2 = new B(); o1 instanceof A => t ...

  6. MAT(Memory Analyzer Tool)工具入门介绍

    1.MAT是什么? MAT(Memory Analyzer Tool),一个基于Eclipse的内存分析工具,是一个快速.功能丰富的JAVA heap分析工具,它可以帮助我们查找内存泄漏和减少内存消耗 ...

  7. css解决select下拉表单option高度的办法

    css在给select下拉表单设置样式如边框时可以轻松搞定,而我们在不喜欢其默认的下拉箭头的样式时试图通过background:url(图片路径)来修改之,则往往会出现浏览器的兼容性问题,在网上查了好 ...

  8. ArcGIS Server 10.1 错误 service failed to start,

    启动发布的地图服务时出现如下错误: ERROR: service failed to start, ServiceStarter thread timeout. 具体原因未知. Google中说了可能 ...

  9. ASPCMS标签教程

    导航栏调用{aspcms:navlist type=0}    <a href="[navlist:link]">[navlist:name]</a>{/a ...

  10. linux笔记六-------文件权限设置

    1.文件(目录)权限本身划分:读read   写write   执行execute 权限从用户的角度划分:主人权限user    同组用户权限group    其他组用户的权限other music. ...