Esempio n. 1
0
        private bool retryInsert(netForumXMLSoapClient xWebClient, out XmlNode queryResults, string objectName, XmlNode oNode)
        {
            bool ret = false;

            queryResults = null;
            for (int i = 0; i < Config.XWebRetryAttemps; i++)
            {
                _log.Error("Retrying insertFacadeObject attempt#: " + i.ToString());
                try
                {
                    queryResults = xWebClient.InsertFacadeObject(ref _authToken, objectName, oNode);
                    if (queryResults != null)
                    {
                        return(true);
                    }
                }
                catch
                {
                    //ignore exception and retry
                }

                Thread.Sleep(Config.XWebRetryWait);
            }

            return(ret);
        }
Esempio n. 2
0
        private XmlNode insertFacadeObject(string objectName, XmlNode oNode, bool isRetry)
        {
            String logMethodName = ".insertFacadeObject(string objectName, XmlNode oNode, 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.InsertFacadeObject(ref ASA.Web.Services.Common.xWeb.AuthorizationToken AuthorizationToken, string szObjectName, System.Xml.XmlNode oNode)");
                logFacadeObject("INSERT", objectName, "", oNode, isRetry);
                queryResults = xWebClient.InsertFacadeObject(ref _authToken, objectName, oNode);
                _log.Debug(logMethodName + "xWebClient.InsertFacadeObject(...) completed");
            }
            catch (TimeoutException te)
            {
                ProxyHelper.HandleServiceException(xWebClient);
                _log.Error(logMethodName + "insertFacadeObject: TimeoutException on xWeb service call.  make sure endpoint is reachable and configured correctly.", te);
                if (!retryInsert(xWebClient, out queryResults, objectName, oNode))
                {
                    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 INSERT 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 insertFacadeObject() following this CommunicationException
                if (isRetry == false && ce.Message.StartsWith("System.Web.Services.Protocols.SoapException: Failed"))
                {
                    ProxyHelper.HandleServiceException(xWebClient);
                    _log.Warn(logMethodName + "Failed to insert data, Communication Exception: Going to retry after getting a new Auth Token");
                    getNewAuthToken();

                    _log.Debug(logMethodName + "Calling netForumXMLSoapClient.InsertFacadeObject(ref ASA.Web.Services.Common.xWeb.AuthorizationToken AuthorizationToken, string szObjectName, System.Xml.XmlNode oNode)");
                    queryResults = insertFacadeObject(objectName, oNode, true);
                    _log.Debug(logMethodName + "xWebClient.InsertFacadeObject(...) completed");

                    //What happens if this throws an exception?
                }
                else
                {
                    _log.Warn(logMethodName + "insertFacadeObject: CommunicationException on xWeb service call.  make sure endpoint is reachable and configured correctly... this may be due to Token expiration", ce);
                    if (!retryInsert(xWebClient, out queryResults, objectName, oNode))
                    {
                        ProxyHelper.HandleServiceException(xWebClient);
                        throw ce;
                    }
                }
            }
            finally
            {
                if (xWebClient.State != CommunicationState.Closed)
                {
                    ProxyHelper.CloseChannel(xWebClient);
                }
            }

            _log.Debug(logMethodName + "End Method");
            return(queryResults);
        }