如何在WCF中增加序列化数据的大小? [英] How to increase the serialization data size in WCF?

查看:91
本文介绍了如何在WCF中增加序列化数据的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的WCF服务在我的数据集表不包含更少的行时工作正常...

当DataSet表包含大数据时,它会给出这样的错误..

My WCF service working fine when my dataset table contain less no rows...

When the DataSet tables contains large data then it gives error like this..

at System.ServiceModel.Channels.CommunicationObject.Close(TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelFactory.OnClose(TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelFactory.TypedServiceChannelFactory`1.OnClose(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Close(TimeSpan timeout)
at System.ServiceModel.ChannelFactory.OnClose(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Close(TimeSpan timeout)
at System.ServiceModel.ChannelFactory.System.IDisposable.Dispose()
at ECMS.UnitTests.TestCurriculumManagement.SyllabusReportRetrieval() in D:\objmap\src\tests\ECMS.ServiceTest\TestCurriculumManagement.cs:line 922




我配置为增加配置文件中的序列化数据的大小...如下所示




i configured to increase the size of serialization data in configuration file...as follows

<bindings>
  <netTcpBinding>
    <binding name="ECMSBindingConfig" maxReceivedMessageSize="8192" maxBufferSize="8192" openTimeout="10:00:00" closeTimeout="10:00:00"  sendTimeout="10:00:00" maxBufferPoolSize="8192" ></binding>
  </netTcpBinding>
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior name="ECMSServiceBehavior">
      <dataContractSerializer maxItemsInObjectGraph="5000"/>
      <serviceDebug includeExceptionDetailInFaults="True" />
      <serviceThrottling maxConcurrentCalls="200" maxConcurrentInstances="100" maxConcurrentSessions="100" />
    </behavior>
  </serviceBehaviors>
</behaviors>



和服务终点是



and Service end point is

<service name="ECMS.Curriculum.Impl.CurriculumManager" behaviorConfiguration="ECMSServiceBehavior">
   <endpoint address="net.tcp://localhost:6775/ECMS.Curriculum.Impl.CurriculumManager" binding="netTcpBinding" bindingConfiguration="ECMSBindingConfig" contract="ECMS.Curriculum.Interface.ICurriculumManagement" />
 </service>




在客户端




in client side

<bindings>
  <netTcpBinding>
    <binding name="ECMSBindingConfig" maxReceivedMessageSize="8192" closeTimeout="10:00:00" maxBufferSize="8192" receiveTimeout="10:00:00"  maxBufferPoolSize="8192" ></binding>
  </netTcpBinding>
</bindings>



谁能帮我解决这个问题...
感谢Adv



can any one help me to solve this problem ...
Thanks in Adv

推荐答案

增加最大缓冲区大小和最大接收消息大小.例如

maxBufferSize ="1000000" maxReceivedMessageSize ="1000000"

完整的绑定可能显示为

Increase the max buffer size and the max received message size. e.g

maxBufferSize="1000000" maxReceivedMessageSize="1000000"

A full binding may read

<basicHttpBinding>
  <binding name="BasicHttpBinding_MyApplication" closeTimeout="00:01:00"

      openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"

      allowCookies="false" bypassProxyOnLocal="true" hostNameComparisonMode="StrongWildcard"

      maxBufferSize="1000000" maxBufferPoolSize="524288" maxReceivedMessageSize="1000000"

      messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"

      useDefaultWebProxy="true">
    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"

        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
    <security mode="TransportCredentialOnly">
      <transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
      <message clientCredentialType="UserName" algorithmSuite="Default" />
    </security>
  </binding>
</basicHttpBinding>


我解决了问题..我如下更改了配置..

i solve the problem .... i changed configuration as follows..

<bindings>
      <netTcpBinding>
        <binding name="ECMSBindingConfig" closeTimeout="00:10:00" openTimeout="00:10:00"

          sendTimeout="00:10:00" maxBufferPoolSize="2147483647" maxBufferSize="2147483647"

          maxReceivedMessageSize="2147483647" portSharingEnabled="true">
          <readerQuotas maxArrayLength="2147483647" maxNameTableCharCount="2147483647"

              maxStringContentLength="2147483647" maxDepth="2147483647"

              maxBytesPerRead="2147483647" />
          <security mode="None" />
        </binding>
      </netTcpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="ECMSServiceBehavior">
          <dataContractSerializer ignoreExtensionDataObject="true" maxItemsInObjectGraph="2147483647" />
          <serviceDebug includeExceptionDetailInFaults="true" />
          <serviceTimeouts transactionTimeout="00:10:00" />
          <serviceThrottling maxConcurrentCalls="200" maxConcurrentSessions="100"

            maxConcurrentInstances="100" />
        </behavior>
      </serviceBehaviors>
    </behaviors>


这篇关于如何在WCF中增加序列化数据的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆