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

简介: 原文:WCF服务接口多,客户端在引用时出错!报WCF The maximum nametable character count quota (16384) has been exceeded while reading XML data错误在服务端中定义接口太多时,在客户端的服务引用时,报错误: 元数据包含无法解析的引用:“net.tcp://localhost:8081/BaseData/mex”。
原文: 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,后再次引用成功! 

 

 

 

目录
打赏
0
0
0
0
216
分享
相关文章
|
10月前
|
Android使用XML-RPC实现blog客户端
Android使用XML-RPC实现blog客户端
87 2
属性和方法向 XML DOM 定义了编程接口
XML DOM 提供编程接口,通过属性和方法操作XML结构。使用JavaScript等语言,可访问和修改节点。属性如nodeName、nodeValue揭示节点信息,方法如getElementsByTagName、appendChild、removeChild实现查找、添加和删除节点功能。节点对象x的应用示例贯穿其中。
属性和方法向 XML DOM 定义了编程接口
XML DOM 是一个编程接口,它将XML表示为节点对象集合,可通过JavaScript等语言访问。接口通过属性和方法定义,属性如nodeName、nodeValue显示节点信息,方法如getElementsByTagName、appendChild、removeChild执行操作。例如,x.nodeName返回节点名称,x.appendChild(node)添加子节点。
XML Web 服务技术解析:WSDL 与 SOAP 原理、应用案例一览
XML Web服务是基于WSDL、SOAP、RDF和RSS等标准的网络应用程序组件技术。WSDL描述服务接口和消息格式,SOAP用于结构化信息交换,RDF描述网络资源,RSS则用于发布网站更新。Web服务特点是自包含、自描述,基于开放协议,可重用且能连接现有软件。WSDL文档包含`types`、`message`、`portType`和`binding`元素,定义服务操作和协议。SOAP协议规定消息格式,通过HTTP等传输。
601 1
支付系统----微信支付20---创建案例项目--集成Mybatis-plus的补充,target下只有接口的编译文件,xml文件了,添加日志的写法
支付系统----微信支付20---创建案例项目--集成Mybatis-plus的补充,target下只有接口的编译文件,xml文件了,添加日志的写法
|
10月前
javaWeb服务详解(含源代码,测试通过,注释) ——web.xml
javaWeb服务详解(含源代码,测试通过,注释) ——web.xml
|
10月前
javaWeb服务详解(含源代码,测试通过,注释) ——applicationContext.xml
javaWeb服务详解(含源代码,测试通过,注释) ——applicationContext.xml
Spring Data JPA入门简解与XML配置实现
Spring Data JPA入门简解与XML配置实现
348 0
|
10月前
|
springboot 项目启动报Has been loaded by XML or SqlProvider, ignoring the injection of the SQL的错误的解决方案
springboot 项目启动报Has been loaded by XML or SqlProvider, ignoring the injection of the SQL的错误的解决方案
1080 0