Class: Savon::GlobalOptions
Instance Method Summary collapse
-
#basic_auth(*credentials) ⇒ Object
HTTP basic auth credentials.
-
#convert_request_keys_to(converter) ⇒ Object
Tell Gyoku how to convert Hash key Symbols to XML tags.
-
#convert_response_tags_to(converter = nil, &block) ⇒ Object
Tell Nori how to convert XML tags from the SOAP response into Hash keys.
-
#digest_auth(*credentials) ⇒ Object
HTTP digest auth credentials.
-
#element_form_default(element_form_default) ⇒ Object
Sets whether elements should be :qualified or unqualified.
-
#encoding(encoding) ⇒ Object
The encoding to use.
-
#endpoint(endpoint) ⇒ Object
SOAP endpoint.
-
#env_namespace(env_namespace) ⇒ Object
Can be used to change the SOAP envelope namespace identifier.
-
#filters(*filters) ⇒ Object
A list of XML tags to filter from logged SOAP messages.
-
#headers(headers) ⇒ Object
A Hash of HTTP headers.
-
#initialize(options = {}) ⇒ GlobalOptions
constructor
A new instance of GlobalOptions.
-
#last_response(last_response) ⇒ Object
Used by Savon to store the last response to pass its cookies to the next request.
-
#log(log) ⇒ Object
Whether or not to log.
-
#log_level(level) ⇒ Object
Changes the Logger's log level.
-
#logger(logger) ⇒ Object
The logger to use.
-
#namespace(namespace) ⇒ Object
Target namespace.
-
#namespace_identifier(identifier) ⇒ Object
The namespace identifer.
-
#open_timeout(open_timeout) ⇒ Object
Open timeout in seconds.
-
#pretty_print_xml(pretty_print_xml) ⇒ Object
Whether to pretty print request and response XML log messages.
-
#proxy(proxy) ⇒ Object
Proxy server to use for all requests.
-
#raise_errors(raise_errors) ⇒ Object
Whether or not to raise SOAP fault and HTTP errors.
-
#read_timeout(read_timeout) ⇒ Object
Read timeout in seconds.
-
#soap_header(header) ⇒ Object
The global SOAP header.
-
#soap_version(soap_version) ⇒ Object
Changes the SOAP version to 1 or 2.
-
#ssl_ca_cert_file(file) ⇒ Object
Sets the ca cert file to use.
-
#ssl_cert_file(file) ⇒ Object
Sets the cert file to use.
-
#ssl_cert_key_file(file) ⇒ Object
Sets the cert key file to use.
-
#ssl_verify_mode(verify_mode) ⇒ Object
Whether and how to to verify the connection.
-
#ssl_version(version) ⇒ Object
Specifies the SSL version to use.
-
#strip_namespaces(strip_namespaces) ⇒ Object
Instruct Nori whether to strip namespaces from XML nodes.
-
#wsdl(wsdl_address) ⇒ Object
Location of the local or remote WSDL document.
-
#wsse_auth(*credentials) ⇒ Object
WSSE auth credentials for Akami.
-
#wsse_timestamp(*timestamp) ⇒ Object
Instruct Akami to enable wsu:Timestamp headers.
Methods inherited from Options
Constructor Details
#initialize(options = {}) ⇒ GlobalOptions
Returns a new instance of GlobalOptions.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/savon/options.rb', line 37 def initialize( = {}) defaults = { :encoding => "UTF-8", :soap_version => 1, :logger => Logger.new($stdout), :filters => [], :pretty_print_xml => false, :raise_errors => true, :strip_namespaces => true, :convert_response_tags_to => lambda { |tag| tag.snakecase.to_sym } } = defaults.merge() # these options are shortcuts on the logger which needs to be set # before it can be modified to set these options. delayed_log = .delete(:log) delayed_level = .delete(:log_level) super() log(delayed_log) unless delayed_log.nil? log_level(delayed_level) unless delayed_level.nil? end |
Instance Method Details
#basic_auth(*credentials) ⇒ Object
HTTP basic auth credentials.
209 210 211 |
# File 'lib/savon/options.rb', line 209 def basic_auth(*credentials) @options[:basic_auth] = credentials.flatten end |
#convert_request_keys_to(converter) ⇒ Object
Tell Gyoku how to convert Hash key Symbols to XML tags. Accepts one of :lower_camelcase, :camelcase, :upcase, or :none.
235 236 237 |
# File 'lib/savon/options.rb', line 235 def convert_request_keys_to(converter) @options[:convert_request_keys_to] = converter end |
#convert_response_tags_to(converter = nil, &block) ⇒ Object
Tell Nori how to convert XML tags from the SOAP response into Hash keys. Accepts a lambda or a block which receives an XML tag and returns a Hash key. Defaults to convert tags to snakecase Symbols.
242 243 244 |
# File 'lib/savon/options.rb', line 242 def (converter = nil, &block) @options[:convert_response_tags_to] = block || converter end |
#digest_auth(*credentials) ⇒ Object
HTTP digest auth credentials.
214 215 216 |
# File 'lib/savon/options.rb', line 214 def digest_auth(*credentials) @options[:digest_auth] = credentials.flatten end |
#element_form_default(element_form_default) ⇒ Object
Sets whether elements should be :qualified or unqualified. If you need to use this option, please open an issue and make sure to add your WSDL document for debugging.
115 116 117 |
# File 'lib/savon/options.rb', line 115 def element_form_default(element_form_default) @options[:element_form_default] = element_form_default end |
#encoding(encoding) ⇒ Object
The encoding to use. Defaults to "UTF-8".
103 104 105 |
# File 'lib/savon/options.rb', line 103 def encoding(encoding) @options[:encoding] = encoding end |
#endpoint(endpoint) ⇒ Object
SOAP endpoint.
68 69 70 |
# File 'lib/savon/options.rb', line 68 def endpoint(endpoint) @options[:endpoint] = endpoint end |
#env_namespace(env_namespace) ⇒ Object
Can be used to change the SOAP envelope namespace identifier. If you need to use this option, please open an issue and make sure to add your WSDL document for debugging.
122 123 124 |
# File 'lib/savon/options.rb', line 122 def env_namespace(env_namespace) @options[:env_namespace] = env_namespace end |
#filters(*filters) ⇒ Object
A list of XML tags to filter from logged SOAP messages.
168 169 170 |
# File 'lib/savon/options.rb', line 168 def filters(*filters) @options[:filters] = filters.flatten end |
#headers(headers) ⇒ Object
A Hash of HTTP headers.
88 89 90 |
# File 'lib/savon/options.rb', line 88 def headers(headers) @options[:headers] = headers end |
#last_response(last_response) ⇒ Object
Used by Savon to store the last response to pass its cookies to the next request.
179 180 181 |
# File 'lib/savon/options.rb', line 179 def last_response(last_response) @options[:last_response] = last_response end |
#log(log) ⇒ Object
Whether or not to log.
137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/savon/options.rb', line 137 def log(log) if log HTTPI.log = true target = $stdout else HTTPI.log = false windows = RUBY_PLATFORM =~ /(mingw|bccwin|wince|mswin32)/i target = windows ? "NUL:" : "/dev/null" end @options[:logger] = Logger.new(target) end |
#log_level(level) ⇒ Object
Changes the Logger's log level.
156 157 158 159 160 161 162 163 164 165 |
# File 'lib/savon/options.rb', line 156 def log_level(level) levels = { :debug => 0, :info => 1, :warn => 2, :error => 3, :fatal => 4 } unless levels.include? level raise ArgumentError, "Invalid log level: #{level.inspect}\n" \ "Expected one of: #{levels.keys.inspect}" end @options[:logger].level = levels[level] end |
#logger(logger) ⇒ Object
The logger to use. Defaults to a Savon::Logger instance.
151 152 153 |
# File 'lib/savon/options.rb', line 151 def logger(logger) @options[:logger] = logger end |
#namespace(namespace) ⇒ Object
Target namespace.
73 74 75 |
# File 'lib/savon/options.rb', line 73 def namespace(namespace) @options[:namespace] = namespace end |
#namespace_identifier(identifier) ⇒ Object
The namespace identifer.
78 79 80 |
# File 'lib/savon/options.rb', line 78 def namespace_identifier(identifier) @options[:namespace_identifier] = identifier end |
#open_timeout(open_timeout) ⇒ Object
Open timeout in seconds.
93 94 95 |
# File 'lib/savon/options.rb', line 93 def open_timeout(open_timeout) @options[:open_timeout] = open_timeout end |
#pretty_print_xml(pretty_print_xml) ⇒ Object
Whether to pretty print request and response XML log messages.
173 174 175 |
# File 'lib/savon/options.rb', line 173 def pretty_print_xml(pretty_print_xml) @options[:pretty_print_xml] = pretty_print_xml end |
#proxy(proxy) ⇒ Object
Proxy server to use for all requests.
83 84 85 |
# File 'lib/savon/options.rb', line 83 def proxy(proxy) @options[:proxy] = proxy end |
#raise_errors(raise_errors) ⇒ Object
Whether or not to raise SOAP fault and HTTP errors.
132 133 134 |
# File 'lib/savon/options.rb', line 132 def raise_errors(raise_errors) @options[:raise_errors] = raise_errors end |
#read_timeout(read_timeout) ⇒ Object
Read timeout in seconds.
98 99 100 |
# File 'lib/savon/options.rb', line 98 def read_timeout(read_timeout) @options[:read_timeout] = read_timeout end |
#soap_header(header) ⇒ Object
The global SOAP header. Expected to be a Hash.
108 109 110 |
# File 'lib/savon/options.rb', line 108 def soap_header(header) @options[:soap_header] = header end |
#soap_version(soap_version) ⇒ Object
Changes the SOAP version to 1 or 2.
127 128 129 |
# File 'lib/savon/options.rb', line 127 def soap_version(soap_version) @options[:soap_version] = soap_version end |
#ssl_ca_cert_file(file) ⇒ Object
Sets the ca cert file to use.
204 205 206 |
# File 'lib/savon/options.rb', line 204 def ssl_ca_cert_file(file) @options[:ssl_ca_cert_file] = file end |
#ssl_cert_file(file) ⇒ Object
Sets the cert file to use.
199 200 201 |
# File 'lib/savon/options.rb', line 199 def ssl_cert_file(file) @options[:ssl_cert_file] = file end |
#ssl_cert_key_file(file) ⇒ Object
Sets the cert key file to use.
194 195 196 |
# File 'lib/savon/options.rb', line 194 def ssl_cert_key_file(file) @options[:ssl_cert_key_file] = file end |
#ssl_verify_mode(verify_mode) ⇒ Object
Whether and how to to verify the connection.
189 190 191 |
# File 'lib/savon/options.rb', line 189 def ssl_verify_mode(verify_mode) @options[:ssl_verify_mode] = verify_mode end |
#ssl_version(version) ⇒ Object
Specifies the SSL version to use.
184 185 186 |
# File 'lib/savon/options.rb', line 184 def ssl_version(version) @options[:ssl_version] = version end |
#strip_namespaces(strip_namespaces) ⇒ Object
Instruct Nori whether to strip namespaces from XML nodes.
229 230 231 |
# File 'lib/savon/options.rb', line 229 def strip_namespaces(strip_namespaces) @options[:strip_namespaces] = strip_namespaces end |
#wsdl(wsdl_address) ⇒ Object
Location of the local or remote WSDL document.
63 64 65 |
# File 'lib/savon/options.rb', line 63 def wsdl(wsdl_address) @options[:wsdl] = wsdl_address end |
#wsse_auth(*credentials) ⇒ Object
WSSE auth credentials for Akami.
219 220 221 |
# File 'lib/savon/options.rb', line 219 def wsse_auth(*credentials) @options[:wsse_auth] = credentials.flatten end |
#wsse_timestamp(*timestamp) ⇒ Object
Instruct Akami to enable wsu:Timestamp headers.
224 225 226 |
# File 'lib/savon/options.rb', line 224 def (*) @options[:wsse_timestamp] = .flatten end |