【问题标题】:Transfer large of data using wcf service使用 wcf 服务传输大量数据
【发布时间】:2012-11-22 08:03:28
【问题描述】:

当我尝试在 WCF 中传输大数据时,我收到此错误:

格式化程序在尝试反序列化 消息:尝试反序列化参数时出错 http://tempuri.org/:requete。 InnerException 消息是“有 反序列化 System.String 类型的对象时出错。最大值 读取 XML 时已超出字符串内容长度配额 (8192) 数据。这个配额可以通过改变 XmlDictionaryReaderQuotas 上的 MaxStringContentLength 属性 创建 XML 阅读器时使用的对象。第 1 行,位置 8843.'。 有关详细信息,请参阅 InnerException。

这是我的app.config 文件:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.web>
    <compilation debug="true" />
  </system.web>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="NewBinding0" maxBufferSize="52428800" maxBufferPoolSize="52428800">
          <readerQuotas maxStringContentLength="52428800" />
        </binding>
      </basicHttpBinding>
    </bindings>
    <services>
      <service name="TSO_WCF.Service1">
        <host>
           <baseAddresses>
               <add baseAddress="http://localhost:8732/Design_Time_Addresses/TSO_WCF/Service1/" />
           </baseAddresses>
        </host>
        <!-- Service Endpoints -->
        <!-- Unless fully qualified, address is relative to base address supplied above -->
        <endpoint address="" binding="wsHttpBinding" contract="TSO_WCF.IService1" >
           <identity>
              <dns value="localhost"/>
           </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <behaviors>
       <serviceBehaviors>
          <behavior>
             <serviceMetadata httpGetEnabled="True"/>
             <serviceDebug includeExceptionDetailInFaults="False" />
          </behavior>
       </serviceBehaviors>
    </behaviors>
</system.serviceModel>
<appSettings>
   <add key="Mapping" value="D:\workspace\oddo.app.ldw.tsomanagertool\ProjetTSO\MappingsXML"/>
</appSettings>
</configuration>

【问题讨论】:

    标签: asp.net wcf maxstringcontentlength


    【解决方案1】:

    您应该增加服务器和客户端绑定的 MaxStringContentLength。此时您使用的是默认值 8192。

    【讨论】:

    • 我已经增加了它,我仍然有同样的错误,我认为我应该改变我的绑定但我不知道如何
    • @user1805523:您必须在 both - 服务器 客户端上进行此配置更改。
    • 您知道如何进行吗?
    【解决方案2】:

    也许你可以改变你的绑定/使用流。看到这个页面:http://msdn.microsoft.com/en-us/library/ms733742.aspx

    【讨论】:

    • 因为我是初学者,所以你有一个更容易的文档
    猜你喜欢
    • 2012-01-03
    • 2011-09-22
    • 1970-01-01
    • 1970-01-01
    • 2011-02-15
    • 2012-02-24
    • 1970-01-01
    • 2012-04-29
    • 2012-09-19
    相关资源
    最近更新 更多