2012-04-17 73 views
1

我在我的项目中使用WCF从服务器(访问数据库)和客户端传输数据,该客户端在屏幕上绘制数据。大量数据通过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

你看过流媒体吗? [大数据和流式传输](http://msdn.microsoft.com/zh-cn/library/ms733742.aspx) – Tim 2012-04-18 00:58:20

回答

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> 
+0

请注意maxItemsInObjectGraph属性,因为这是OP正在查找的内容。 – Chris 2012-04-17 22:21:13

+0

我做了,它的设置高于应该导致错误的设置。 6553600> 86400.默认值为65536.似乎较大的值无法识别。也许是由于行为。 – richk 2012-04-17 22:24:56

+0

最大值是2147483647. – richk 2012-04-17 22:26:22