我有一个 json 字符串列表,我试图循环并发布到 WebService。它遍历前两个就好了,然后在第 3 次迭代时停止(这发生在第 14 行)。没有错误或任何东西,它似乎停止了。有任何想法吗?
private static void CacheGetDataUrl(Guid sessionGuid)
{
var tokens = Driver.GetDataPostValues();
foreach (var token in tokens)
{
try
{
var buffer = Encoding.UTF8.GetBytes(token.Replace("session_identifier", sessionGuid.ToString()));
var request = (HttpWebRequest)WebRequest.Create(GetDataUrl);
request.Timeout = 1000000;
request.Method = "POST";
request.ContentType = "application/json; charset=utf-8";
request.ContentLength = buffer.Length;
using (var postData = request.GetRequestStream())
{
postData.Write(buffer, 0, buffer.Length);
postData.Close();
}
Console.WriteLine("Response requested for URL {0}", GetDataUrl);
Log.Info(String.Format("Response requested for URL {0} using parameters \r\n{1}", GetDataUrl, token));
}
catch (Exception)
{
Console.WriteLine("Error occurred requesting response for URL {0} using parameters \r\n{1}", GetDataUrl, token);
Log.Error(String.Format("Error occurred requesting response for URL {0} using parameters \r\n{1}", GetDataUrl, token));
}
}
}