Class: Savon::GlobalOptions
- Includes:
- HTTPITransportOptions, SharedOptions
- Defined in:
- lib/savon/options.rb
Overview
Client-level options applied to every request made by a Savon::Client instance. Covers service location, SOAP configuration, logging, response parsing, and transport selection. HTTPI-specific options (proxy, timeouts, SSL, auth) come from HTTPITransportOptions.
Constant Summary
Constants included from HTTPITransportOptions
HTTPITransportOptions::FARADAY_INCOMPATIBLE_GLOBALS
Instance Attribute Summary
Attributes inherited from Options
Instance Method Summary collapse
-
#convert_attributes_to(converter = nil, &block) ⇒ Object
Tell Nori how to convert XML attributes on tags from the SOAP response into Hash keys.
-
#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.
-
#delete_namespace_attributes(delete_namespace_attributes) ⇒ Object
Instruct Nori whether to delete namespace attributes from XML nodes.
-
#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 sent with every request.
-
#host(host) ⇒ Object
Set a different host for actions in the WSDL.
-
#initialize(options = {}) ⇒ GlobalOptions
constructor
A new instance of GlobalOptions.
-
#log(log) ⇒ Object
Whether or not to log.
-
#log_headers(log_headers) ⇒ Object
Whether to log headers.
-
#log_level(level) ⇒ Object
Changes the Logger's log level.
-
#logger(logger) ⇒ Object
The logger to use.
-
#multipart(multipart) ⇒ Object
Instruct Savon to create a multipart response if available.
-
#namespace(namespace) ⇒ Object
Target namespace.
-
#namespace_identifier(identifier) ⇒ Object
The namespace identifier.
-
#namespaces(namespaces) ⇒ Object
Namespaces for the SOAP envelope.
-
#no_message_tag(bool) ⇒ Object
Suppress the message tag wrapper around the SOAP body.
-
#pretty_print_xml(pretty_print_xml) ⇒ Object
Whether to pretty print request and response XML log messages.
-
#raise_errors(raise_errors) ⇒ Object
Whether or not to raise SOAP fault and HTTP errors.
-
#soap_header(header) ⇒ Object
The global SOAP header.
-
#soap_version(soap_version) ⇒ Object
Changes the SOAP version to 1 or 2.
-
#strip_namespaces(strip_namespaces) ⇒ Object
Instruct Nori whether to strip namespaces from XML nodes.
-
#transport(transport) ⇒ Object
HTTP transport to use.
-
#unwrap(unwrap) ⇒ Object
Tell Gyoku to unwrap Array of Hashes.
-
#use_wsa_headers(use) ⇒ Object
Enable inclusion of WS-Addressing headers.
-
#wsdl(wsdl_address) ⇒ Object
Location of the local or remote WSDL document.
Methods included from HTTPITransportOptions
#adapter, #basic_auth, #digest_auth, #follow_redirects, #ntlm, #open_timeout, #proxy, #read_timeout, #ssl_ca_cert, #ssl_ca_cert_file, #ssl_ca_cert_path, #ssl_cert, #ssl_cert_file, #ssl_cert_key, #ssl_cert_key_file, #ssl_cert_key_password, #ssl_cert_store, #ssl_ciphers, #ssl_max_version, #ssl_min_version, #ssl_verify_mode, #ssl_version, #validate_transport!, #write_timeout
Methods included from SharedOptions
#wsse_auth, #wsse_signature, #wsse_timestamp
Methods inherited from Options
Constructor Details
#initialize(options = {}) ⇒ GlobalOptions
Returns a new instance of GlobalOptions.
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 |
# File 'lib/savon/options.rb', line 272 def initialize( = {}) @option_type = :global defaults = { encoding: "UTF-8", soap_version: 1, namespaces: {}, logger: Logger.new($stdout), log: false, log_headers: true, filters: [], pretty_print_xml: false, raise_errors: true, strip_namespaces: true, delete_namespace_attributes: false, convert_response_tags_to: ->(tag) { StringUtils.snakecase(tag).to_sym }, convert_attributes_to: ->(k, v) { [k, v] }, multipart: false, use_wsa_headers: false, no_message_tag: false, unwrap: false, host: nil, transport: :httpi, # httpi transport defaults adapter: nil, follow_redirects: false } = defaults.merge() # this option is a shortcut on the logger which needs to be set # before it can be modified to set the option. delayed_level = .delete(:log_level) super() log_level(delayed_level) unless delayed_level.nil? end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Savon::Options
Instance Method Details
#convert_attributes_to(converter = nil, &block) ⇒ Object
Tell Nori how to convert XML attributes on 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 doing nothing.
452 453 454 |
# File 'lib/savon/options.rb', line 452 def convert_attributes_to(converter = nil, &block) [:convert_attributes_to] = block || converter 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.
432 433 434 |
# File 'lib/savon/options.rb', line 432 def convert_request_keys_to(converter) [: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 converting tags to snakecase Symbols.
445 446 447 |
# File 'lib/savon/options.rb', line 445 def (converter = nil, &block) [:convert_response_tags_to] = block || converter end |
#delete_namespace_attributes(delete_namespace_attributes) ⇒ Object
Instruct Nori whether to delete namespace attributes from XML nodes.
426 427 428 |
# File 'lib/savon/options.rb', line 426 def delete_namespace_attributes(delete_namespace_attributes) [:delete_namespace_attributes] = delete_namespace_attributes 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.
360 361 362 |
# File 'lib/savon/options.rb', line 360 def element_form_default(element_form_default) [:element_form_default] = element_form_default end |
#encoding(encoding) ⇒ Object
The encoding to use. Defaults to "UTF-8".
348 349 350 |
# File 'lib/savon/options.rb', line 348 def encoding(encoding) [:encoding] = encoding end |
#endpoint(endpoint) ⇒ Object
SOAP endpoint.
323 324 325 |
# File 'lib/savon/options.rb', line 323 def endpoint(endpoint) [: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.
367 368 369 |
# File 'lib/savon/options.rb', line 367 def env_namespace(env_namespace) [:env_namespace] = env_namespace end |
#filters(*filters) ⇒ Object
A list of XML tags to filter from logged SOAP messages.
411 412 413 |
# File 'lib/savon/options.rb', line 411 def filters(*filters) [:filters] = filters.flatten end |
#headers(headers) ⇒ Object
A Hash of HTTP headers sent with every request.
343 344 345 |
# File 'lib/savon/options.rb', line 343 def headers(headers) [:headers] = headers end |
#host(host) ⇒ Object
Set a different host for actions in the WSDL.
318 319 320 |
# File 'lib/savon/options.rb', line 318 def host(host) [:host] = host end |
#log(log) ⇒ Object
Whether or not to log.
382 383 384 385 |
# File 'lib/savon/options.rb', line 382 def log(log) HTTPI.log = log [:log] = log end |
#log_headers(log_headers) ⇒ Object
Whether to log headers.
406 407 408 |
# File 'lib/savon/options.rb', line 406 def log_headers(log_headers) [:log_headers] = log_headers end |
#log_level(level) ⇒ Object
Changes the Logger's log level.
394 395 396 397 398 399 400 401 402 403 |
# File 'lib/savon/options.rb', line 394 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 [:logger].level = levels[level] end |
#logger(logger) ⇒ Object
The logger to use. Defaults to a Savon::Logger instance.
388 389 390 391 |
# File 'lib/savon/options.rb', line 388 def logger(logger) HTTPI.logger = logger [:logger] = logger end |
#multipart(multipart) ⇒ Object
Instruct Savon to create a multipart response if available.
457 458 459 |
# File 'lib/savon/options.rb', line 457 def multipart(multipart) [:multipart] = multipart end |
#namespace(namespace) ⇒ Object
Target namespace.
328 329 330 |
# File 'lib/savon/options.rb', line 328 def namespace(namespace) [:namespace] = namespace end |
#namespace_identifier(identifier) ⇒ Object
The namespace identifier.
333 334 335 |
# File 'lib/savon/options.rb', line 333 def namespace_identifier(identifier) [:namespace_identifier] = identifier end |
#namespaces(namespaces) ⇒ Object
Namespaces for the SOAP envelope.
338 339 340 |
# File 'lib/savon/options.rb', line 338 def namespaces(namespaces) [:namespaces] = namespaces end |
#no_message_tag(bool) ⇒ Object
Suppress the message tag wrapper around the SOAP body.
467 468 469 |
# File 'lib/savon/options.rb', line 467 def (bool) [:no_message_tag] = bool end |
#pretty_print_xml(pretty_print_xml) ⇒ Object
Whether to pretty print request and response XML log messages.
416 417 418 |
# File 'lib/savon/options.rb', line 416 def pretty_print_xml(pretty_print_xml) [:pretty_print_xml] = pretty_print_xml end |
#raise_errors(raise_errors) ⇒ Object
Whether or not to raise SOAP fault and HTTP errors.
377 378 379 |
# File 'lib/savon/options.rb', line 377 def raise_errors(raise_errors) [:raise_errors] = raise_errors end |
#soap_header(header) ⇒ Object
The global SOAP header. Expected to be a Hash or responding to #to_s.
353 354 355 |
# File 'lib/savon/options.rb', line 353 def soap_header(header) [:soap_header] = header end |
#soap_version(soap_version) ⇒ Object
Changes the SOAP version to 1 or 2.
372 373 374 |
# File 'lib/savon/options.rb', line 372 def soap_version(soap_version) [:soap_version] = soap_version end |
#strip_namespaces(strip_namespaces) ⇒ Object
Instruct Nori whether to strip namespaces from XML nodes.
421 422 423 |
# File 'lib/savon/options.rb', line 421 def strip_namespaces(strip_namespaces) [:strip_namespaces] = strip_namespaces end |
#transport(transport) ⇒ Object
HTTP transport to use. Accepts :httpi (default) or :faraday. When set to :faraday, configure transport concerns directly on the Faraday::Connection returned by client.faraday instead of using the HTTPITransportOptions.
475 476 477 |
# File 'lib/savon/options.rb', line 475 def transport(transport) [:transport] = transport end |
#unwrap(unwrap) ⇒ Object
Tell Gyoku to unwrap Array of Hashes. Accepts a boolean, defaults to false.
438 439 440 |
# File 'lib/savon/options.rb', line 438 def unwrap(unwrap) [:unwrap] = unwrap end |
#use_wsa_headers(use) ⇒ Object
Enable inclusion of WS-Addressing headers.
462 463 464 |
# File 'lib/savon/options.rb', line 462 def use_wsa_headers(use) [:use_wsa_headers] = use end |
#wsdl(wsdl_address) ⇒ Object
Location of the local or remote WSDL document.
313 314 315 |
# File 'lib/savon/options.rb', line 313 def wsdl(wsdl_address) [:wsdl] = wsdl_address end |