2012-12-04 60 views
3

当我尝试在WCF传输大数据的数据,我得到这个错误:传输大使用WCF服务

The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:requete . The InnerException message was 'There was an error deserializing the object of type System.String. The maximum string content length quota (8192) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. Line 1, position 8843.'. Please see InnerException for more details.

这是我的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> 

回答

3

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

+0

我增加了它我仍然有同样的错误,我认为我应该更改绑定但我不知道如何 – user1805523

+0

@ user1805523:你将不得不在** **和**客户端**上进行配置更改。 –

+0

您有关于如何继续的想法吗? – user1805523