class Savon::GlobalOptions

Public Class Methods

new(options = {}) click to toggle source
Calls superclass method Savon::Options::new
# File lib/savon/options.rb, line 72
    def initialize(options = {})
      @option_type = :global

      defaults = {
        :encoding                  => "UTF-8",
        :soap_version              => 1,
        :namespaces                => {},
#        :logger                    => Logger.new($stdout),
        :log                       => false,
        :filters                   => [],
        :pretty_print_xml          => false,
        :raise_errors              => true,
        :strip_namespaces          => true,
        :convert_response_tags_to  => lambda { |tag| tag.snakecase.to_sym},
        :convert_attributes_to     => lambda { |k,v| [k,v] },
        :multipart                 => false,
        :adapter                   => nil,
        :use_wsa_headers           => false,
        :no_message_tag            => false,
        :follow_redirects          => false,
        :unwrap                    => false,
        :host                      => nil
      }

      options = defaults.merge(options)

      # this option is a shortcut on the logger which needs to be set
      # before it can be modified to set the option.
      delayed_level = options.delete(:log_level)

      super(options)

      log_level(delayed_level) unless delayed_level.nil?
    end

Public Instance Methods

adapter(adapter) click to toggle source

Instruct Savon what HTTPI adapter it should use instead of default

# File lib/savon/options.rb, line 323
def adapter(adapter)
  @options[:adapter] = adapter
end
basic_auth(*credentials) click to toggle source

HTTP basic auth credentials.

# File lib/savon/options.rb, line 272
def basic_auth(*credentials)
  @options[:basic_auth] = credentials.flatten
end
convert_attributes_to(converter = nil, &block) click to toggle source

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

# File lib/savon/options.rb, line 313
def convert_attributes_to(converter = nil, &block)
  @options[:convert_attributes_to] = block || converter
end
convert_request_keys_to(converter) click to toggle source

Tell Gyoku how to convert Hash key Symbols to XML tags. Accepts one of :lower_camelcase, :camelcase, :upcase, or :none.

# File lib/savon/options.rb, line 293
def convert_request_keys_to(converter)
  @options[:convert_request_keys_to] = converter
end
convert_response_tags_to(converter = nil, &block) click to toggle source

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.

# File lib/savon/options.rb, line 306
def convert_response_tags_to(converter = nil, &block)
  @options[:convert_response_tags_to] = block || converter
end
digest_auth(*credentials) click to toggle source

HTTP digest auth credentials.

# File lib/savon/options.rb, line 277
def digest_auth(*credentials)
  @options[:digest_auth] = credentials.flatten
end
element_form_default(element_form_default) click to toggle source

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.

# File lib/savon/options.rb, line 170
def element_form_default(element_form_default)
  @options[:element_form_default] = element_form_default
end
encoding(encoding) click to toggle source

The encoding to use. Defaults to “UTF-8”.

# File lib/savon/options.rb, line 158
def encoding(encoding)
  @options[:encoding] = encoding
end
endpoint(endpoint) click to toggle source

SOAP endpoint.

# File lib/savon/options.rb, line 118
def endpoint(endpoint)
  @options[:endpoint] = endpoint
end
env_namespace(env_namespace) click to toggle source

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.

# File lib/savon/options.rb, line 177
def env_namespace(env_namespace)
  @options[:env_namespace] = env_namespace
end
filters(*filters) click to toggle source

A list of XML tags to filter from logged SOAP messages.

# File lib/savon/options.rb, line 216
def filters(*filters)
  @options[:filters] = filters.flatten
end
follow_redirects(follow_redirects) click to toggle source

Instruct requests to follow HTTP redirects.

# File lib/savon/options.rb, line 337
def follow_redirects(follow_redirects)
  @options[:follow_redirects] = follow_redirects
end
headers(headers) click to toggle source

A Hash of HTTP headers.

# File lib/savon/options.rb, line 143
def headers(headers)
  @options[:headers] = headers
end
host(host) click to toggle source

set different host for actions in WSDL

# File lib/savon/options.rb, line 113
def host(host)
  @options[:host] = host
end
log(log) click to toggle source

Whether or not to log.

# File lib/savon/options.rb, line 192
def log(log)
  HTTPI.log = log
  @options[:log] = log
end
log_level(level) click to toggle source

Changes the Logger’s log level.

# File lib/savon/options.rb, line 204
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) click to toggle source

The logger to use. Defaults to a Savon::Logger instance.

# File lib/savon/options.rb, line 198
def logger(logger)
  HTTPI.logger = logger
  @options[:logger] = logger
end
multipart(multipart) click to toggle source

Instruct Savon to create a multipart response if available.

# File lib/savon/options.rb, line 318
def multipart(multipart)
  @options[:multipart] = multipart
end
namespace(namespace) click to toggle source

Target namespace.

# File lib/savon/options.rb, line 123
def namespace(namespace)
  @options[:namespace] = namespace
end
namespace_identifier(identifier) click to toggle source

The namespace identifer.

# File lib/savon/options.rb, line 128
def namespace_identifier(identifier)
  @options[:namespace_identifier] = identifier
end
namespaces(namespaces) click to toggle source

Namespaces for the SOAP envelope.

# File lib/savon/options.rb, line 133
def namespaces(namespaces)
  @options[:namespaces] = namespaces
end
no_message_tag(bool) click to toggle source
# File lib/savon/options.rb, line 332
def no_message_tag(bool)
  @options[:no_message_tag] = bool
end
ntlm(*credentials) click to toggle source

NTLM auth credentials.

# File lib/savon/options.rb, line 282
def ntlm(*credentials)
  @options[:ntlm] = credentials.flatten
end
open_timeout(open_timeout) click to toggle source

Open timeout in seconds.

# File lib/savon/options.rb, line 148
def open_timeout(open_timeout)
  @options[:open_timeout] = open_timeout
end
pretty_print_xml(pretty_print_xml) click to toggle source

Whether to pretty print request and response XML log messages.

# File lib/savon/options.rb, line 221
def pretty_print_xml(pretty_print_xml)
  @options[:pretty_print_xml] = pretty_print_xml
end
proxy(proxy) click to toggle source

Proxy server to use for all requests.

# File lib/savon/options.rb, line 138
def proxy(proxy)
  @options[:proxy] = proxy
end
raise_errors(raise_errors) click to toggle source

Whether or not to raise SOAP fault and HTTP errors.

# File lib/savon/options.rb, line 187
def raise_errors(raise_errors)
  @options[:raise_errors] = raise_errors
end
read_timeout(read_timeout) click to toggle source

Read timeout in seconds.

# File lib/savon/options.rb, line 153
def read_timeout(read_timeout)
  @options[:read_timeout] = read_timeout
end
soap_header(header) click to toggle source

The global SOAP header. Expected to be a Hash or responding to to_s.

# File lib/savon/options.rb, line 163
def soap_header(header)
  @options[:soap_header] = header
end
soap_version(soap_version) click to toggle source

Changes the SOAP version to 1 or 2.

# File lib/savon/options.rb, line 182
def soap_version(soap_version)
  @options[:soap_version] = soap_version
end
ssl_ca_cert(cert) click to toggle source

Sets the ca cert to use.

# File lib/savon/options.rb, line 266
def ssl_ca_cert(cert)
  @options[:ssl_ca_cert] = cert
end
ssl_ca_cert_file(file) click to toggle source

Sets the ca cert file to use.

# File lib/savon/options.rb, line 261
def ssl_ca_cert_file(file)
  @options[:ssl_ca_cert_file] = file
end
ssl_cert(cert) click to toggle source

Sets the cert to use.

# File lib/savon/options.rb, line 256
def ssl_cert(cert)
  @options[:ssl_cert] = cert
end
ssl_cert_file(file) click to toggle source

Sets the cert file to use.

# File lib/savon/options.rb, line 251
def ssl_cert_file(file)
  @options[:ssl_cert_file] = file
end
ssl_cert_key(key) click to toggle source

Sets the cert key to use.

# File lib/savon/options.rb, line 241
def ssl_cert_key(key)
  @options[:ssl_cert_key] = key
end
ssl_cert_key_file(file) click to toggle source

Sets the cert key file to use.

# File lib/savon/options.rb, line 236
def ssl_cert_key_file(file)
  @options[:ssl_cert_key_file] = file
end
ssl_cert_key_password(password) click to toggle source

Sets the cert key password to use.

# File lib/savon/options.rb, line 246
def ssl_cert_key_password(password)
  @options[:ssl_cert_key_password] = password
end
ssl_verify_mode(verify_mode) click to toggle source

Whether and how to to verify the connection.

# File lib/savon/options.rb, line 231
def ssl_verify_mode(verify_mode)
  @options[:ssl_verify_mode] = verify_mode
end
ssl_version(version) click to toggle source

Specifies the SSL version to use.

# File lib/savon/options.rb, line 226
def ssl_version(version)
  @options[:ssl_version] = version
end
strip_namespaces(strip_namespaces) click to toggle source

Instruct Nori whether to strip namespaces from XML nodes.

# File lib/savon/options.rb, line 287
def strip_namespaces(strip_namespaces)
  @options[:strip_namespaces] = strip_namespaces
end
unwrap(unwrap) click to toggle source

Tell Gyoku to unwrap Array of Hashes Accepts a boolean, default to false

# File lib/savon/options.rb, line 299
def unwrap(unwrap)
  @options[:unwrap] = unwrap
end
use_wsa_headers(use) click to toggle source

Enable inclusion of WS-Addressing headers.

# File lib/savon/options.rb, line 328
def use_wsa_headers(use)
  @options[:use_wsa_headers] = use
end
wsdl(wsdl_address) click to toggle source

Location of the local or remote WSDL document.

# File lib/savon/options.rb, line 108
def wsdl(wsdl_address)
  @options[:wsdl] = wsdl_address
end