I found that sometimes, if I have an error "The remote name could not be resolved" to access remote web services, I should re-try the call and it helps.
I've considered to increase timeout for WebServices method call, but some methods,e.g. DataSet.ReadXml (String) doesn't have the option.
So I've created a static method that will retry remote call a few times. The actual function to call can be passed as delegate:
public class WSClientHelper
{
public delegate void CallWebServiceDelegate ();
public static void RetryWebServiceCall(int nRetry, CallWebServiceDelegate dlgt)
{ // I beleive that it's a good idea to re-try in case of "The remote name could not be resolved"
for (int i = 0; i < nRetry; i++)
{
try
{
dlgt();// ds = ReadRssUrlAsDataSet(timeStart, url);
break;
}
catch (WebException exc)
{
if (exc.Message.Contains("The remote name could not be resolved") && (i < nRetry-1))
{ DebugHelper.TracedLine("Attempt " + i.ToString() + " failed." +exc.Message);
continue;//try n times
}
throw;
}
}
}
}
The sample to use utilizes C# anonymous delegates(new for .Net 2.0), which makes the use very compact and simple
FSCSharpLib.ASP.WSClientHelper.RetryWebServiceCall(3, delegate
{
//Yo can put any code you like with unrestricted access to local variables and class members
ds = ReadRssUrlAsDataSet(timeStart, url); //just sample method
});