private bool retryGet(netForumXMLSoapClient xWebClient, out XmlNode queryResults, string objectName, string columnList, string whereClause, string orderBy) { bool ret = false; queryResults = null; for (int i = 0; i < Config.XWebRetryAttemps; i++) { _log.Error("Retrying getQuery attempt#: " + i.ToString()); try { queryResults = xWebClient.GetQuery(ref _authToken, objectName, columnList, whereClause, orderBy); if (queryResults != null) { return(true); } } catch { //ignore exception and retry } Thread.Sleep(Config.XWebRetryWait); } return(ret); }
private XmlNode getQuery(string objectName, string columnList, string whereClause, string orderBy, bool isRetry) { String logMethodName = ".getQuery(string objectName, string columnList, string whereClause, string orderBy, 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 Successfully"); logGetQuery(objectName, columnList, whereClause, orderBy, isRetry); _log.Debug(logMethodName + "Calling netForumXMLSoapClient.GetQuery(ref ASA.Web.Services.Common.xWeb.AuthorizationToken AuthorizationToken, string szObjectName, string szColumnList, string szWhereClause, string szOrderBy)"); queryResults = xWebClient.GetQuery(ref _authToken, objectName, columnList, whereClause, orderBy); _log.Debug(logMethodName + "xWebClient.GetQuery(...) completed"); } catch (TimeoutException te) { _log.Error(logMethodName + "getQuery: TimeoutException on xWeb service call. make sure endpoint is reachable and configured correctly.", te); if (!retryGet(xWebClient, out queryResults, objectName, columnList, whereClause, orderBy)) { 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 GET operation: " + objectName, fe); // throw fe; //} catch (CommunicationException ce) { _log.Error(logMethodName + "There has been an error attempting to communicate with XWeb, attempting retry (if enabled)", 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 + "getQuery: Going to retry after getting a new Auth Token"); getNewAuthToken(); _log.Debug(logMethodName + "Calling netForumXMLSoapClient.GetQuery(ref ASA.Web.Services.Common.xWeb.AuthorizationToken AuthorizationToken, string szObjectName, string szColumnList, string szWhereClause, string szOrderBy)"); queryResults = getQuery(objectName, columnList, whereClause, orderBy, true); _log.Debug(logMethodName + "xWebClient.GetQuery(...) completed"); } else { _log.Warn(logMethodName + "getQuery: CommunicationException on xWeb service call. make sure endpoint is reachable and configured correctly... this may be due to Token expiration", ce); if (!retryGet(xWebClient, out queryResults, objectName, columnList, whereClause, orderBy)) { ProxyHelper.HandleServiceException(xWebClient); throw ce; } } } finally { if (xWebClient.State != CommunicationState.Closed) { ProxyHelper.CloseChannel(xWebClient); } } _log.Debug(logMethodName + "End Method"); return(queryResults); }