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 3732 题解

    3732: Network Description 给你N个点的无向图 (1 <= N <= 15,000),记为:1…N. 图中有M条边 (1 <= M <= 30,000) ...

  2. Android -- 服务组件的使用(1)

    1. 效果图

  3. static的本质

    通过反编译发现,static的本质是abstract sealed.因此,无法继承System.Math类,因为它是static的.

  4. GO语言练习:map基本用法

    1.代码 2.运行 1.代码 文件:map.go package main import "fmt" type PersionInfo struct{ ID string Name ...

  5. java 深入浅出工厂模式

    一.引子 话说十年前,有一个暴发户,他家有三辆汽车——Benz奔驰.Bmw宝马.Audi奥迪,还雇了司机为他开车.不过,暴发户坐车时总是怪怪的:上Benz车后跟司机说“开奔驰车!”,坐上Bmw后他说“ ...

  6. 给自定义cell赋值代码

    // //  ViewController.m //  11 - 投资管理 - 李洪强 // //  Created by vic fan on 16/4/8. //  Copyright © 201 ...

  7. [MetroUI-1]无边框模式

    Wpf中取消边框,使用 WindowStyle="None" AllowsTransparency="True"

  8. 特殊集合 Stack Queue Hashtable

    //Stack    干草堆集合    栈集合      先进后出 Stack st = new Stack(); //实例化 初始化 st.Push(2); //添加元素 st.Push(6); s ...

  9. django数据库动态添加列

    方法一: python manage.py migrate 方法二: python manage.py migrate 效果: ---〉

  10. 从show slave status 中判断mysql同步状态

    slave status 中检查同步状态: 1.sql线程和io线程显示yes Slave_IO_Running: Yes Slave_SQL_Running: Yes 2. Master_Log_F ...