我在项目中使用WCF从服务器(访问数据库)和客户端传输数据,客户端在屏幕上绘制数据。
转移数据的数量相当大,所以我想知道哪种方法最好。
现在,我能够查询少量数据,大约3600个对象(时间戳和双值)。但是,当此数字增加到大约86400个对象时,将发生服务函数调用中的错误。
我的服务和客户声明如下:
服务器:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata/>
<dataContractSerializer maxItemsInObjectGraph="6553600"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="serviceName">
<endpoint binding="netTcpBinding" contract="interfaceName">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:5050/msservice"/>
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
客户端:
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_IService" closeTimeout="00:02:00" openTimeout="00:02:00" receiveTimeout="00:10:00" sendTimeout="00:02:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxConnections="10" maxBufferSize="2147483647" maxBufferPoolSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false"/>
<security mode="Transport">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign"/>
<message clientCredentialType="Windows"/>
</security>
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://localhost:5050/msservice" binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IService" contract="IService" name="NetTcpBinding_IService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
</client>
</system.serviceModel>
答案 0 :(得分:1)
你在.net 4吗?如果不是,我相信您需要提供服务行为的名称并将其与服务相关联。
编辑:否则,可以使用默认的maxItemsInObjectGraph值65536。
<system.serviceModel>
<services>
<service name="YOURPROJECT.Web.YOURSERVICE"
behaviorConfiguration="YOURPROJECT-Web-YOURSERVICE">
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="YOURPROJECT-Web-YOURSERVICE">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="6553600"/>
</behavior>
</serviceBehaviors>
</behaviors>