private bool retryExecute(netForumXMLSoapClient xWebClient, out XmlNode queryResults, string serviceName, string methodName, Parameter[] parameters) { bool ret = false; queryResults = null; for (int i = 0; i < Config.XWebRetryAttemps; i++) { _log.Error("Retrying ExecuteMethod attempt#: " + i.ToString()); try { queryResults = xWebClient.ExecuteMethod(ref _authToken, serviceName, methodName, parameters); if (queryResults != null) { return(true); } } catch { //ignore exception and retry } Thread.Sleep(Config.XWebRetryWait); } return(ret); }
private XmlNode executeMethod(string serviceName, string methodName, Parameter[] parameters, bool isRetry) { String logMethodName = ".executeMethod(string serviceName, string methodName, Parameter[] parameters, bool isRetry) - "; _log.Debug(logMethodName + "Begin Method"); XmlNode queryResults = null; netForumXMLSoapClient xWebClient = null; try { _log.Debug(logMethodName + "Creating netForumXMLSoapClient."); xWebClient = new netForumXMLSoapClient(); _log.Debug(logMethodName + "netForumXMLSoapClient created successfuly."); _log.Debug(logMethodName + "Calling netForumXMLSoapClient.ExecuteMethod(ASA.Web.Services.Common.xWeb.ExecuteMethodRequest request)"); logExecuteMethod(serviceName, methodName, parameters, isRetry); queryResults = xWebClient.ExecuteMethod(ref _authToken, serviceName, methodName, parameters); _log.Debug(logMethodName + "netForumXMLSoapClient.ExecuteMethod(...) completed"); } catch (TimeoutException te) { _log.Error(logMethodName + "executeMethod: TimeoutException on xWeb service call. make sure endpoint is reachable and configured correctly.", te); if (!retryExecute(xWebClient, out queryResults, serviceName, methodName, parameters)) { ProxyHelper.HandleServiceException(xWebClient); throw te; } } //we do not want to retry these. These are errors that will not be fixed by a retry, i.e. invalid credentials //catch (FaultException fe) //{ // _log.Error(logMethodName + "There has been an error for an xWeb Execute operation: ", fe); // throw fe; //} catch (CommunicationException ce) { // This will cause the AuthorizationToken to be refreshed, // and it will perform ONE retry call to xWeb to GetQuery() following this CommunicationException if (isRetry == false && ce.Message.StartsWith("System.Web.Services.Protocols.SoapException: Failed")) { ProxyHelper.HandleServiceException(xWebClient); _log.Info(logMethodName + "executeMethod: Going to retry after getting a new Auth Token"); getNewAuthToken(); queryResults = executeMethod(serviceName, methodName, parameters, true); } else { _log.Error(logMethodName + "executeMethod: CommunicationException on xWeb service call. make sure endpoint is reachable and configured correctly... this may be due to Token expiration", ce); if (!retryExecute(xWebClient, out queryResults, serviceName, methodName, parameters)) { ProxyHelper.HandleServiceException(xWebClient); throw ce; } } } finally { if (xWebClient.State != CommunicationState.Closed) { ProxyHelper.CloseChannel(xWebClient); } } _log.Debug(logMethodName + "End Method"); return(queryResults); }