【问题标题】:Returning large collectionresult set from WCF从 WCF 返回大型集合结果集
【发布时间】:2017-01-12 00:15:03
【问题描述】:

我正在尝试从 WCF 服务返回大型结果集。大型结果集可能有大约 50 万条记录,每条记录有 150 列。

我知道通过配置 WCF 绑定,我们可以返回大型结果集。但我不确定这个限制。我尝试了这种情况,但即使我将值设置为该属性的“2147483647”,也会增加“maxItemsInObjectGraph”属性的限制。我搜索了替代选项,发现这可以通过 Binding 的 messageEncoding 和 transferMode 属性来实现。我尝试了“Mtom”和“StreamResponse”,但我不确定它是如何工作的?

我还提到了this 链接,但不想进行分页,因为我的客户需要一次性获取数据。

所以结论是:

1. Can we return large result set from WCF? Or Does the use of WCF best to return large result set or I need to move to different way like WebAPI?
2. StreamResponse should work like returning results in chunck I guess but after implementation, I don't think it is working as I am getting result altogether.

您的意见将不胜感激。

谢谢!!

【问题讨论】:

    标签: json xml wcf wcf-data-services wcf-binding


    【解决方案1】:
    1. 您可以从 WCF 服务返回大型对象集。考虑到传输大量数据,WebAPI 或其他 .NET 服务框架没有优势。
    2. StreamResponse 是您的最佳选择。它逐部分传输消息,因此您不会在某一时刻将所有 500K 记录都在线传输。这是一个传输层选项,因此对于客户来说,他似乎一次得到了整个消息。您可以通过编辑绑定的 MaxBufferSize 属性来管理该部分的大小。 要最小化数据大小,您还可以使用 BinaryMessageEncoding 对其进行压缩。

      <customBinding>
      <binding name="primaryBinding" openTimeout="00:01:00"  closeTimeout="00:01:00" 
                sendTimeout="00:30:00" receiveTimeout="00:30:00">
        <binaryMessageEncoding compressionFormat="GZip">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
                        maxArrayLength="2147483647" maxBytesPerRead="2147483647"
                        maxNameTableCharCount="2147483647" />
        </binaryMessageEncoding>
        <httpsTransport transferMode="Streamed" maxReceivedMessageSize="6000000" 
                        maxBufferSize="6000000" maxBufferPoolSize="12000000" />          
      </binding>      
      

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-26
      • 2012-12-18
      • 1970-01-01
      相关资源
      最近更新 更多