Class: Savon::GlobalOptions

Inherits:
Options
  • Object
show all
Includes:
SharedOptions
Defined in:
lib/savon/options.rb

Instance Attribute Summary

Attributes inherited from Options

#option_type

Instance Method Summary collapse

Methods included from SharedOptions

#wsse_auth, #wsse_signature, #wsse_timestamp

Methods inherited from Options

#[], #[]=, #include?

Constructor Details

#initialize(options = {}) ⇒ GlobalOptions

Returns a new instance of GlobalOptions.



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/savon/options.rb', line 73

def initialize(options = {})
  @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    => lambda { |tag| StringUtils.snakecase(tag).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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Savon::Options

Instance Method Details

#adapter(adapter) ⇒ Object

Instruct Savon what HTTPI adapter it should use instead of default



364
365
366
# File 'lib/savon/options.rb', line 364

def adapter(adapter)
  @options[:adapter] = adapter
end

#basic_auth(*credentials) ⇒ Object

HTTP basic auth credentials.



308
309
310
# File 'lib/savon/options.rb', line 308

def basic_auth(*credentials)
  @options[:basic_auth] = credentials.flatten
end

#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



354
355
356
# File 'lib/savon/options.rb', line 354

def convert_attributes_to(converter = nil, &block)
  @options[: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.



334
335
336
# File 'lib/savon/options.rb', line 334

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.



347
348
349
# File 'lib/savon/options.rb', line 347

def convert_response_tags_to(converter = nil, &block)
  @options[:convert_response_tags_to] = block || converter
end

#delete_namespace_attributes(delete_namespace_attributes) ⇒ Object

Instruct Nori whether to delete namespace attributes from XML nodes.



328
329
330
# File 'lib/savon/options.rb', line 328

def delete_namespace_attributes(delete_namespace_attributes)
  @options[:delete_namespace_attributes] = delete_namespace_attributes
end

#digest_auth(*credentials) ⇒ Object

HTTP digest auth credentials.



313
314
315
# File 'lib/savon/options.rb', line 313

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.



178
179
180
# File 'lib/savon/options.rb', line 178

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”.



166
167
168
# File 'lib/savon/options.rb', line 166

def encoding(encoding)
  @options[:encoding] = encoding
end

#endpoint(endpoint) ⇒ Object

SOAP endpoint.



121
122
123
# File 'lib/savon/options.rb', line 121

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.



185
186
187
# File 'lib/savon/options.rb', line 185

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.



229
230
231
# File 'lib/savon/options.rb', line 229

def filters(*filters)
  @options[:filters] = filters.flatten
end

#follow_redirects(follow_redirects) ⇒ Object

Instruct requests to follow HTTP redirects.



378
379
380
# File 'lib/savon/options.rb', line 378

def follow_redirects(follow_redirects)
  @options[:follow_redirects] = follow_redirects
end

#headers(headers) ⇒ Object

A Hash of HTTP headers.



146
147
148
# File 'lib/savon/options.rb', line 146

def headers(headers)
  @options[:headers] = headers
end

#host(host) ⇒ Object

set different host for actions in WSDL



116
117
118
# File 'lib/savon/options.rb', line 116

def host(host)
  @options[:host] = host
end

#log(log) ⇒ Object

Whether or not to log.



200
201
202
203
# File 'lib/savon/options.rb', line 200

def log(log)
  HTTPI.log = log
  @options[:log] = log
end

#log_headers(log_headers) ⇒ Object

To log headers or not.



224
225
226
# File 'lib/savon/options.rb', line 224

def log_headers(log_headers)
  @options[:log_headers] = log_headers
end

#log_level(level) ⇒ Object

Changes the Logger’s log level.



212
213
214
215
216
217
218
219
220
221
# File 'lib/savon/options.rb', line 212

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.



206
207
208
209
# File 'lib/savon/options.rb', line 206

def logger(logger)
  HTTPI.logger = logger
  @options[:logger] = logger
end

#multipart(multipart) ⇒ Object

Instruct Savon to create a multipart response if available.



359
360
361
# File 'lib/savon/options.rb', line 359

def multipart(multipart)
  @options[:multipart] = multipart
end

#namespace(namespace) ⇒ Object

Target namespace.



126
127
128
# File 'lib/savon/options.rb', line 126

def namespace(namespace)
  @options[:namespace] = namespace
end

#namespace_identifier(identifier) ⇒ Object

The namespace identifer.



131
132
133
# File 'lib/savon/options.rb', line 131

def namespace_identifier(identifier)
  @options[:namespace_identifier] = identifier
end

#namespaces(namespaces) ⇒ Object

Namespaces for the SOAP envelope.



136
137
138
# File 'lib/savon/options.rb', line 136

def namespaces(namespaces)
  @options[:namespaces] = namespaces
end

#no_message_tag(bool) ⇒ Object



373
374
375
# File 'lib/savon/options.rb', line 373

def no_message_tag(bool)
  @options[:no_message_tag] = bool
end

#ntlm(*credentials) ⇒ Object

NTLM auth credentials.



318
319
320
# File 'lib/savon/options.rb', line 318

def ntlm(*credentials)
  @options[:ntlm] = credentials.flatten
end

#open_timeout(open_timeout) ⇒ Object

Open timeout in seconds.



151
152
153
# File 'lib/savon/options.rb', line 151

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.



234
235
236
# File 'lib/savon/options.rb', line 234

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.



141
142
143
# File 'lib/savon/options.rb', line 141

def proxy(proxy)
  @options[:proxy] = proxy unless proxy.nil?
end

#raise_errors(raise_errors) ⇒ Object

Whether or not to raise SOAP fault and HTTP errors.



195
196
197
# File 'lib/savon/options.rb', line 195

def raise_errors(raise_errors)
  @options[:raise_errors] = raise_errors
end

#read_timeout(read_timeout) ⇒ Object

Read timeout in seconds.



156
157
158
# File 'lib/savon/options.rb', line 156

def read_timeout(read_timeout)
  @options[:read_timeout] = read_timeout
end

#soap_header(header) ⇒ Object

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



171
172
173
# File 'lib/savon/options.rb', line 171

def soap_header(header)
  @options[:soap_header] = header
end

#soap_version(soap_version) ⇒ Object

Changes the SOAP version to 1 or 2.



190
191
192
# File 'lib/savon/options.rb', line 190

def soap_version(soap_version)
  @options[:soap_version] = soap_version
end

#ssl_ca_cert(cert) ⇒ Object

Sets the ca cert to use.



289
290
291
# File 'lib/savon/options.rb', line 289

def ssl_ca_cert(cert)
  @options[:ssl_ca_cert] = cert
end

#ssl_ca_cert_file(file) ⇒ Object

Sets the ca cert file to use.



284
285
286
# File 'lib/savon/options.rb', line 284

def ssl_ca_cert_file(file)
  @options[:ssl_ca_cert_file] = file
end

#ssl_ca_cert_path(path) ⇒ Object

Sets the ca cert path.



298
299
300
# File 'lib/savon/options.rb', line 298

def ssl_ca_cert_path(path)
  @options[:ssl_ca_cert_path] = path
end

#ssl_cert(cert) ⇒ Object

Sets the cert to use.



279
280
281
# File 'lib/savon/options.rb', line 279

def ssl_cert(cert)
  @options[:ssl_cert] = cert
end

#ssl_cert_file(file) ⇒ Object

Sets the cert file to use.



274
275
276
# File 'lib/savon/options.rb', line 274

def ssl_cert_file(file)
  @options[:ssl_cert_file] = file
end

#ssl_cert_key(key) ⇒ Object

Sets the cert key to use.



264
265
266
# File 'lib/savon/options.rb', line 264

def ssl_cert_key(key)
  @options[:ssl_cert_key] = key
end

#ssl_cert_key_file(file) ⇒ Object

Sets the cert key file to use.



259
260
261
# File 'lib/savon/options.rb', line 259

def ssl_cert_key_file(file)
  @options[:ssl_cert_key_file] = file
end

#ssl_cert_key_password(password) ⇒ Object

Sets the cert key password to use.



269
270
271
# File 'lib/savon/options.rb', line 269

def ssl_cert_key_password(password)
  @options[:ssl_cert_key_password] = password
end

#ssl_cert_store(store) ⇒ Object

Sets the ssl cert store.



303
304
305
# File 'lib/savon/options.rb', line 303

def ssl_cert_store(store)
  @options[:ssl_cert_store] = store
end

#ssl_ciphers(ciphers) ⇒ Object



293
294
295
# File 'lib/savon/options.rb', line 293

def ssl_ciphers(ciphers)
  @options[:ssl_ciphers] = ciphers
end

#ssl_max_version(version) ⇒ Object

Specifies the SSL version to use.



249
250
251
# File 'lib/savon/options.rb', line 249

def ssl_max_version(version)
  @options[:ssl_max_version] = version
end

#ssl_min_version(version) ⇒ Object

Specifies the SSL version to use.



244
245
246
# File 'lib/savon/options.rb', line 244

def ssl_min_version(version)
  @options[:ssl_min_version] = version
end

#ssl_verify_mode(verify_mode) ⇒ Object

Whether and how to to verify the connection.



254
255
256
# File 'lib/savon/options.rb', line 254

def ssl_verify_mode(verify_mode)
  @options[:ssl_verify_mode] = verify_mode
end

#ssl_version(version) ⇒ Object

Specifies the SSL version to use.



239
240
241
# File 'lib/savon/options.rb', line 239

def ssl_version(version)
  @options[:ssl_version] = version
end

#strip_namespaces(strip_namespaces) ⇒ Object

Instruct Nori whether to strip namespaces from XML nodes.



323
324
325
# File 'lib/savon/options.rb', line 323

def strip_namespaces(strip_namespaces)
  @options[:strip_namespaces] = strip_namespaces
end

#unwrap(unwrap) ⇒ Object

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



340
341
342
# File 'lib/savon/options.rb', line 340

def unwrap(unwrap)
  @options[:unwrap] = unwrap
end

#use_wsa_headers(use) ⇒ Object

Enable inclusion of WS-Addressing headers.



369
370
371
# File 'lib/savon/options.rb', line 369

def use_wsa_headers(use)
  @options[:use_wsa_headers] = use
end

#write_timeout(write_timeout) ⇒ Object

Write timeout in seconds.



161
162
163
# File 'lib/savon/options.rb', line 161

def write_timeout(write_timeout)
  @options[:write_timeout] = write_timeout
end

#wsdl(wsdl_address) ⇒ Object

Location of the local or remote WSDL document.



111
112
113
# File 'lib/savon/options.rb', line 111

def wsdl(wsdl_address)
  @options[:wsdl] = wsdl_address
end