/// <summary> /// Generates new token to be used for ArcGIS server requests. /// </summary> /// <returns>New token which can be used for ArcGIS server requests.</returns> public string GenerateToken() { if (!_authenticator.RequiresTokens) { throw new InvalidOperationException( Properties.Messages.Error_TokenAuthNotSupported); } string token = null; try { token = _authenticator.GenerateToken(_parameters.Credentials); } catch (AuthenticationException e) { throw ServiceHelper.CreateAuthException(_server, e); } catch (Exception e) { if (ServiceHelper.IsCommunicationError(e)) { throw ServiceHelper.CreateCommException(_server, e); } throw; } return(token); }
private Exception _ConvertCommException(Exception ex) { if (ServiceHelper.IsCommunicationError(ex)) { return(ServiceHelper.CreateCommException(_connection.Title, ex)); } return(ex); }
/// <summary> /// Translates the specified exception into the more application-specific /// one. /// </summary> /// <param name="exception">The exception to be translated.</param> /// <returns>Translated exception or null reference if the exception /// cannot be translated.</returns> private Exception _TranslateException(Exception exception) { if (ServiceHelper.IsCommunicationError(exception) || exception is SerializationException) { return(ServiceHelper.CreateCommException(_serviceTitle, exception)); } return(null); }
/// <summary> /// Translates the specified exceptions into ones specific for /// <see cref="QueryServiceUrl"/> method. /// </summary> /// <param name="exception">The exception to be translated.</param> /// <returns>Translated exception or null if the exception cannot be /// translated and the original one should be thrown.</returns> private Exception _TranslateExceptions(Exception exception) { var isCommunicationError = exception is FaultException || ServiceHelper.IsCommunicationError(exception); if (isCommunicationError) { return(ServiceHelper.CreateCommException(_serverTitle, exception)); } return(null); }
/// <summary> /// Invokes service method that returns a value of type T. /// </summary> protected T Invoke <T>(ServiceMethod <T> method) { const int maxRetryCount = 1; int retryCount = 0; while (true) { var client = _AcquireClient(); try { return(method.Invoke(client)); } catch (Exception e) { if (ProxyAuthenticationErrorHandler.HandleError(e)) { continue; } var isTokenError = _IsTokenError(e); if (retryCount >= maxRetryCount || !isTokenError) { if (ServiceHelper.IsCommunicationError(e)) { throw ServiceHelper.CreateCommException( _connection.Title, e); } throw; } if (isTokenError) { _connection.GenerateToken(); _CloseClient(client); client = null; } ++retryCount; } finally { _ReleaseClient(client); } } }
private CommunicationException _CreateCommException(Exception ex) { return(ServiceHelper.CreateCommException(this, ex)); }