private bool retryUpdate(netForumXMLSoapClient xWebClient, out XmlNode queryResults, string objectName, XmlNode oNode, string objectKey) { bool ret = false; queryResults = null; for (int i = 0; i < Config.XWebRetryAttemps; i++) { _log.Error("Retrying updateFacadeObject attempt#: " + i.ToString()); try { queryResults = xWebClient.UpdateFacadeObject(ref _authToken, objectName, objectKey, oNode); if (queryResults != null) { return(true); } } catch { //ignore exception and retry } Thread.Sleep(Config.XWebRetryWait); } return(ret); }
private XmlNode updateFacadeObject(string objectName, string objectKey, XmlNode oNode, bool isRetry) { String logMethodName = ".updateFacadeObject(string objectName, string objectKey, XmlNode oNode, bool isRetry) - "; _log.Debug(logMethodName + "Begin Method"); XmlNode queryResults = null; netForumXMLSoapClient xWebClient = null; try { //throw new CommunicationException(); _log.Debug(logMethodName + "Creating netForumXMLSoapClient."); xWebClient = new netForumXMLSoapClient(); _log.Debug(logMethodName + "netForumXMLSoapClient created successfuly."); _log.Debug(logMethodName + "Calling netForumXMLSoapClient.UpdateFacadeObjectResponse ASA.Web.Services.Common.xWeb.netForumXMLSoap.UpdateFacadeObject(ASA.Web.Services.Common.xWeb.UpdateFacadeObjectRequest request)"); logFacadeObject("UPDATE", objectName, objectKey, oNode, isRetry); queryResults = xWebClient.UpdateFacadeObject(ref _authToken, objectName, objectKey, oNode); _log.Debug(logMethodName + "netForumXMLSoapClient.UpdateFacadeObject(...) completed"); } catch (TimeoutException te) { _log.Error(logMethodName + "updateFacadeObject: TimeoutException on xWeb service call. make sure endpoint is reachable and configured correctly.", te); if (!retryUpdate(xWebClient, out queryResults, objectName, oNode, objectKey)) { 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 UPDATE operation: ", 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 + "updateFacadeObject: Going to retry after getting a new Auth Token"); getNewAuthToken(); _log.Debug(logMethodName + "Calling netForumXMLSoapClient.UpdateFacadeObjectResponse ASA.Web.Services.Common.xWeb.netForumXMLSoap.UpdateFacadeObject(ASA.Web.Services.Common.xWeb.UpdateFacadeObjectRequest request)"); queryResults = updateFacadeObject(objectName, objectKey, oNode, true); _log.Debug(logMethodName + "netForumXMLSoapClient.UpdateFacadeObject(...) completed"); //what happens if this throws an exception? } else { _log.Warn(logMethodName + "updateFacadeObject: CommunicationException on xWeb service call. make sure endpoint is reachable and configured correctly... this may be due to Token expiration", ce); if (!retryUpdate(xWebClient, out queryResults, objectName, oNode, objectKey)) { ProxyHelper.HandleServiceException(xWebClient); throw ce; } } } finally { if (xWebClient.State != CommunicationState.Closed) { ProxyHelper.CloseChannel(xWebClient); } } _log.Debug(logMethodName + "End Method"); return(queryResults); }