使用Foreach循环消耗大量WebServices

时间:2018-11-08 17:51:25

标签: c# list loops http foreach

本质上,我的程序需要消耗大约100个(并且这个数字将扩展)WebServices,从每个WebServices中提取一条数据,对其进行存储,解析然后显示。我已经编写了用于存储,解析和显示的代码。

我的问题是:在网上找不到任何有关如何遍历WebReferences列表并查询每个WebReferences的教程。我注定要编写100个WebReferences并手动为每个查询编写查询,还是可以存储URL(或某些东西)的列表或数组并循环浏览?还是有另一种更好的方法?

我专门对此进行了研究,但还没有发现任何东西,我已经进行了尽职调查。我不是在问关于如何使用WebService的问题,关于它的信息很多,而且并不难。

当前的foreach循环(不足,因为我需要传递登录凭据并获得响应):

//Retrieve the XMLString from the server
//The ServerURLList is just a giant list of URLS, I didn't include it
var client = new WebClient { Credentials = new NetworkCredential("LoginCredentials", "LoginCredentialsPass") };
var XMLStringFromServer = client.DownloadString((String)(dr[0])); 
//Notice it takes the string URL from the DataTable provided, so that it can do all 100 customers while parsing the response

0 个答案:

没有答案