lib/ratis/request.rb in ratis-3.5.0 vs lib/ratis/request.rb in ratis-3.6.0
- old
+ new
@@ -2,24 +2,10 @@
class Request
extend Savon::Model
- def initialize(config = nil)
- config = Ratis.config if config.nil?
- raise Errors::ConfigError('It appears that Ratis.configure has not been called or properly setup') unless config.valid?
-
- self.class.client do
- wsdl.endpoint = Ratis.config.endpoint
- wsdl.namespace = Ratis.config.namespace
- http.proxy = Ratis.config.proxy unless Ratis.config.proxy.blank?
- http.open_timeout = Ratis.config.timeout unless Ratis.config.timeout.blank?
- end
- rescue ArgumentError => e
- raise ArgumentError.new 'Invalid ATIS SOAP server configuration: ' + e.message
- end
-
def self.get(action, params = {})
begin
raise Errors::ConfigError, 'It appears that Ratis.configure has not been called or properly setup' unless Ratis.config.valid?
# Merge in the Appid as set in the configuration.
@@ -29,22 +15,25 @@
# Necessary since calling Ratis.configure doesn't allow changing of values set during Savon initialization
# Savon memoizes the client config
endpoint(Ratis.config.endpoint)
namespace(Ratis.config.namespace)
+ client.http.read_timeout = Ratis.config.timeout
+
response = client.request action, :soap_action => "#{Ratis.config.namespace}##{action}", :xmlns => Ratis.config.namespace do
soap.body = params unless params.blank?
end
# version = response.to_hash["#{action.downcase}_response".to_sym][:version]
response
rescue Errno::ECONNREFUSED => e
- raise Errno::ECONNREFUSED.new 'Refused request to ATIS SOAP server'
+ raise Errors::NetworkError.new 'Refused request to ATIS SOAP server', e
rescue Savon::SOAP::Fault => e
raise Errors::SoapError.new e
rescue Timeout::Error => e
- raise "TIMEOUT!"
+ msg = "Request to ATIS SOAP server timed out after #{ Ratis.config.timeout }s"
+ raise Errors::NetworkError.new msg, e
end
end
end