Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/299.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cassandra/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 通过流发送从缓慢的外部web服务接收的大量数据_C#_Web Services_Rest_Wcf - Fatal编程技术网

C# 通过流发送从缓慢的外部web服务接收的大量数据

C# 通过流发送从缓慢的外部web服务接收的大量数据,c#,web-services,rest,wcf,C#,Web Services,Rest,Wcf,我使用WCF编写了小型RESTWeb服务。这些web服务将作为其他更专业的web服务的门面 所以它看起来像: Java应用程序(客户端)我的Rest WCF Web服务外部Web服务 [OperationContract] [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare, U

我使用WCF编写了小型RESTWeb服务。这些web服务将作为其他更专业的web服务的门面

所以它看起来像: Java应用程序(客户端)我的Rest WCF Web服务外部Web服务

    [OperationContract]
    [WebInvoke(Method = "GET",
        ResponseFormat = WebMessageFormat.Json,
        BodyStyle = WebMessageBodyStyle.Bare,
        UriTemplate = "/GetListOfRecordByRootId/{userid}/{rootId}")]
    List<RecordDTO> GetListOfRecordByRootId(string userid, string rootId);
[运营合同]
[WebInvoke(Method=“GET”,
ResponseFormat=WebMessageFormat.Json,
BodyStyle=WebMessageBodyStyle.Bare,
UriTemplate=“/GetListOfRecordByRootId/{userid}/{rootId}”)]
List GetListOfRecordByRootId(字符串用户ID、字符串根ID);
但它是这样工作的:

public List<TimeSeriesDto> GetListOfTimeseriesByDataSetId(string guid, string dataSetId, string numberOfSeries)
{
    Var client = this.OpenToExternalWebservice();
    return client.GetDataByRootId.ToList();
}
public List GetListOfTimeseriesByDataSetId(字符串guid、字符串dataSetId、字符串numberOfSeries)
{
Var client=this.OpenToExternalWebservice();
返回client.getDataByRotid.ToList();
}
其中OpenToExternalWebservice打开到web服务的连接。但我遇到了一个严重的问题->数据量。 事实证明,外部Web服务速度非常慢,而且非常有限。结果是巨大的我收到了超过200MB的结果

问题:是否可以以chuncked方式通过流返回数据? 让我们给你举个小例子:

DataAtrot有10万条记录

步骤1)我从外部web服务下载前1000条记录

步骤2)收到后,我将其转换为:列表。然后我将它打包到json usign DataContactJsonSerializer

步骤3)在将它们转换为Json后,我wamt通过流发送它,但我不想关闭连接

步骤4)删除我发送的旧记录

步骤5)返回到步骤1(获取下1000条记录)

所以我的梦想是通过流发送许多记录列表:

接收下一部分数据后,我将在其中放置的一个流:

List<Record> Row Number 0-999
List<Record> Row Number 1000-1999
List<Record> Row Number 2000-2999
List<Record> Row Number 3000-3999
列出行号0-999
列表行编号1000-1999
列表行编号2000-2999
列表行编号3000-3999

可能吗?或者你有其他的解决方案吗


请帮帮我。非常感谢您的帮助,任何答案取决于通过线路传输的数据是什么?它是XML。Json、txt、csv还是其他什么?据我所知,没有简单的方法可以做到这一点,但如果您知道它将采用的格式,您可以编写一个聪明的流式服务来缓冲接收到的数据包,侦听“记录结束”组合,无论是XML结束标记还是换行符。获取累积的数据,然后将其转发给接收方,同时继续从发送方接收更多数据包。记录有两个字段-序列号和bool lastDTO。如果某些数据是最后一个数据,则Last DTO将设置为true。外部web服务是SOAP服务。因此,我将以XML的形式接收它。但我只能一次请求1000条记录(即使root有2mln条记录)。所以请求-1000条记录,下一个请求1000条记录。但是java应用程序只会问我一次,所以我想知道我是否可以通过一个流(不关闭)发送多个包,只是为了澄清一下,您正在编写的代理服务是用C语言编写的,对吗?对,绝对是用C语言编写的。