savon 2.18.1 → 3.0.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -158
- data/README.md +53 -74
- data/Rakefile +2 -6
- data/lib/savon/block_interface.rb +4 -3
- data/lib/savon/builder.rb +48 -119
- data/lib/savon/client.rb +13 -44
- data/lib/savon/header.rb +40 -87
- data/lib/savon/http_error.rb +9 -9
- data/lib/savon/log_message.rb +4 -52
- data/lib/savon/message.rb +6 -18
- data/lib/savon/mock/expectation.rb +24 -38
- data/lib/savon/mock/spec_helper.rb +11 -7
- data/lib/savon/mock.rb +0 -1
- data/lib/savon/model.rb +30 -44
- data/lib/savon/operation.rb +90 -118
- data/lib/savon/options.rb +176 -292
- data/lib/savon/qualified_message.rb +10 -91
- data/lib/savon/request.rb +147 -0
- data/lib/savon/request_logger.rb +57 -0
- data/lib/savon/response.rb +31 -45
- data/lib/savon/soap_fault.rb +6 -6
- data/lib/savon/string_utils.rb +4 -3
- data/lib/savon/version.rb +1 -2
- data/lib/savon.rb +10 -5
- metadata +119 -75
- data/lib/savon/addressing.rb +0 -60
- data/lib/savon/effective_options.rb +0 -139
- data/lib/savon/faraday_migration_hint.rb +0 -186
- data/lib/savon/transport/faraday.rb +0 -105
- data/lib/savon/transport/header_validation.rb +0 -62
- data/lib/savon/transport/httpi.rb +0 -142
- data/lib/savon/transport/logging.rb +0 -67
- data/lib/savon/transport/response.rb +0 -73
data/lib/savon/options.rb
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
|
|
3
2
|
require "logger"
|
|
4
|
-
require "httpi"
|
|
5
|
-
require "savon/faraday_migration_hint"
|
|
6
3
|
|
|
7
4
|
module Savon
|
|
8
|
-
# Base class for GlobalOptions and LocalOptions.
|
|
9
|
-
# Stores options in a hash, dispatches setter calls by method name,
|
|
10
|
-
# raises UnknownOptionError for anything not defined on the subclass.
|
|
11
5
|
class Options
|
|
6
|
+
|
|
12
7
|
def initialize(options = {})
|
|
13
8
|
@options = {}
|
|
14
9
|
assign options
|
|
15
10
|
end
|
|
16
11
|
|
|
12
|
+
def deprecate(option)
|
|
13
|
+
raise DeprecatedOptionError.new(option)
|
|
14
|
+
end
|
|
15
|
+
|
|
17
16
|
attr_reader :option_type
|
|
18
17
|
|
|
19
18
|
def [](option)
|
|
@@ -22,7 +21,7 @@ module Savon
|
|
|
22
21
|
|
|
23
22
|
def []=(option, value)
|
|
24
23
|
value = [value].flatten
|
|
25
|
-
send(option, *value)
|
|
24
|
+
self.send(option, *value)
|
|
26
25
|
end
|
|
27
26
|
|
|
28
27
|
def include?(option)
|
|
@@ -33,7 +32,7 @@ module Savon
|
|
|
33
32
|
|
|
34
33
|
def assign(options)
|
|
35
34
|
options.each do |option, value|
|
|
36
|
-
send(option, value)
|
|
35
|
+
self.send(option, value)
|
|
37
36
|
end
|
|
38
37
|
end
|
|
39
38
|
|
|
@@ -42,8 +41,6 @@ module Savon
|
|
|
42
41
|
end
|
|
43
42
|
end
|
|
44
43
|
|
|
45
|
-
# Options available in both GlobalOptions and LocalOptions.
|
|
46
|
-
# Currently covers WSSE authentication and timestamp headers.
|
|
47
44
|
module SharedOptions
|
|
48
45
|
# WSSE auth credentials for Akami.
|
|
49
46
|
# Local will override the global wsse_auth value, e.g.
|
|
@@ -52,12 +49,11 @@ module Savon
|
|
|
52
49
|
# global == [user, pass] && local == nil => [user, pass]
|
|
53
50
|
def wsse_auth(*credentials)
|
|
54
51
|
credentials.flatten!
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
end
|
|
52
|
+
if credentials.size == 1
|
|
53
|
+
@options[:wsse_auth] = credentials.first
|
|
54
|
+
else
|
|
55
|
+
@options[:wsse_auth] = credentials
|
|
56
|
+
end
|
|
61
57
|
end
|
|
62
58
|
|
|
63
59
|
# Instruct Akami to enable wsu:Timestamp headers.
|
|
@@ -74,186 +70,35 @@ module Savon
|
|
|
74
70
|
end
|
|
75
71
|
end
|
|
76
72
|
|
|
77
|
-
# Options that belong to HTTPI's transport layer.
|
|
78
|
-
#
|
|
79
|
-
# They still work with the default HTTPI transport. With `transport: :faraday`,
|
|
80
|
-
# Savon does not translate them because Faraday exposes its own setup API for
|
|
81
|
-
# proxy, timeout, TLS, auth, redirects, and adapter choices.
|
|
82
|
-
module HTTPITransportOptions
|
|
83
|
-
TRANSPORT_DEFAULTS = {
|
|
84
|
-
adapter: nil,
|
|
85
|
-
follow_redirects: false
|
|
86
|
-
}.freeze
|
|
87
|
-
|
|
88
|
-
# These are rejected for `transport: :faraday` once the caller has set a
|
|
89
|
-
# non-default value. The error points to the matching Faraday setup.
|
|
90
|
-
FARADAY_INCOMPATIBLE_GLOBALS = FaradayMigrationHint::OPTIONS
|
|
91
|
-
|
|
92
|
-
# Runs after all global options have been assigned, including options set in
|
|
93
|
-
# the client block. Reports every HTTPI-only option in one error so callers
|
|
94
|
-
# can move their transport setup to Faraday in one pass.
|
|
95
|
-
def validate_transport!
|
|
96
|
-
return unless self[:transport] == :faraday
|
|
97
|
-
|
|
98
|
-
unless faraday_loaded?
|
|
99
|
-
raise InitializationError,
|
|
100
|
-
"transport: :faraday requires the faraday gem.\n" \
|
|
101
|
-
"Add to your Gemfile: gem 'faraday'"
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
violations = FARADAY_INCOMPATIBLE_GLOBALS.filter_map { |option|
|
|
105
|
-
next unless include?(option)
|
|
106
|
-
next if default_transport_option?(option)
|
|
107
|
-
|
|
108
|
-
FaradayMigrationHint.new(option, self[option]).message
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return if violations.empty?
|
|
112
|
-
|
|
113
|
-
raise InitializationError,
|
|
114
|
-
"The following options are not supported with transport: :faraday:\n#{violations.join("\n")}"
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
# Proxy server to use for all requests.
|
|
118
|
-
def proxy(proxy)
|
|
119
|
-
@options[:proxy] = proxy unless proxy.nil?
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
# Open timeout in seconds.
|
|
123
|
-
def open_timeout(open_timeout)
|
|
124
|
-
@options[:open_timeout] = open_timeout
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
# Read timeout in seconds.
|
|
128
|
-
def read_timeout(read_timeout)
|
|
129
|
-
@options[:read_timeout] = read_timeout
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
# Write timeout in seconds.
|
|
133
|
-
def write_timeout(write_timeout)
|
|
134
|
-
@options[:write_timeout] = write_timeout
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
# Specifies the SSL version to use.
|
|
138
|
-
def ssl_version(version)
|
|
139
|
-
@options[:ssl_version] = version
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
# Specifies the minimum SSL version to use.
|
|
143
|
-
def ssl_min_version(version)
|
|
144
|
-
@options[:ssl_min_version] = version
|
|
145
|
-
end
|
|
146
|
-
|
|
147
|
-
# Specifies the maximum SSL version to use.
|
|
148
|
-
def ssl_max_version(version)
|
|
149
|
-
@options[:ssl_max_version] = version
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
# Whether and how to verify the SSL connection.
|
|
153
|
-
def ssl_verify_mode(verify_mode)
|
|
154
|
-
@options[:ssl_verify_mode] = verify_mode
|
|
155
|
-
end
|
|
156
|
-
|
|
157
|
-
# Sets the cert key file to use.
|
|
158
|
-
def ssl_cert_key_file(file)
|
|
159
|
-
@options[:ssl_cert_key_file] = file
|
|
160
|
-
end
|
|
161
|
-
|
|
162
|
-
# Sets the cert key to use.
|
|
163
|
-
def ssl_cert_key(key)
|
|
164
|
-
@options[:ssl_cert_key] = key
|
|
165
|
-
end
|
|
166
|
-
|
|
167
|
-
# Sets the cert key password to use.
|
|
168
|
-
def ssl_cert_key_password(password)
|
|
169
|
-
@options[:ssl_cert_key_password] = password
|
|
170
|
-
end
|
|
171
|
-
|
|
172
|
-
# Sets the cert file to use.
|
|
173
|
-
def ssl_cert_file(file)
|
|
174
|
-
@options[:ssl_cert_file] = file
|
|
175
|
-
end
|
|
176
|
-
|
|
177
|
-
# Sets the cert to use.
|
|
178
|
-
def ssl_cert(cert)
|
|
179
|
-
@options[:ssl_cert] = cert
|
|
180
|
-
end
|
|
181
|
-
|
|
182
|
-
# Sets the CA cert file to use.
|
|
183
|
-
def ssl_ca_cert_file(file)
|
|
184
|
-
@options[:ssl_ca_cert_file] = file
|
|
185
|
-
end
|
|
186
|
-
|
|
187
|
-
# Sets the CA cert to use.
|
|
188
|
-
def ssl_ca_cert(cert)
|
|
189
|
-
@options[:ssl_ca_cert] = cert
|
|
190
|
-
end
|
|
191
|
-
|
|
192
|
-
# Sets the SSL ciphers to use.
|
|
193
|
-
def ssl_ciphers(ciphers)
|
|
194
|
-
@options[:ssl_ciphers] = ciphers
|
|
195
|
-
end
|
|
196
|
-
|
|
197
|
-
# Sets the CA cert path.
|
|
198
|
-
def ssl_ca_cert_path(path)
|
|
199
|
-
@options[:ssl_ca_cert_path] = path
|
|
200
|
-
end
|
|
201
|
-
|
|
202
|
-
# Sets the SSL cert store.
|
|
203
|
-
def ssl_cert_store(store)
|
|
204
|
-
@options[:ssl_cert_store] = store
|
|
205
|
-
end
|
|
206
|
-
|
|
207
|
-
# HTTP basic auth credentials.
|
|
208
|
-
def basic_auth(*credentials)
|
|
209
|
-
@options[:basic_auth] = credentials.flatten
|
|
210
|
-
end
|
|
211
|
-
|
|
212
|
-
# HTTP digest auth credentials.
|
|
213
|
-
def digest_auth(*credentials)
|
|
214
|
-
@options[:digest_auth] = credentials.flatten
|
|
215
|
-
end
|
|
216
|
-
|
|
217
|
-
# NTLM auth credentials.
|
|
218
|
-
def ntlm(*credentials)
|
|
219
|
-
@options[:ntlm] = credentials.flatten
|
|
220
|
-
end
|
|
221
|
-
|
|
222
|
-
# Instruct requests to follow HTTP redirects.
|
|
223
|
-
def follow_redirects(follow_redirects)
|
|
224
|
-
@options[:follow_redirects] = follow_redirects
|
|
225
|
-
end
|
|
226
|
-
|
|
227
|
-
# Instruct Savon which HTTPI adapter to use instead of the default.
|
|
228
|
-
def adapter(adapter)
|
|
229
|
-
@options[:adapter] = adapter
|
|
230
|
-
end
|
|
231
|
-
|
|
232
|
-
private
|
|
233
|
-
|
|
234
|
-
def default_transport_option?(option)
|
|
235
|
-
TRANSPORT_DEFAULTS.key?(option) && self[option] == TRANSPORT_DEFAULTS[option]
|
|
236
|
-
end
|
|
237
|
-
|
|
238
|
-
# Attempts to load faraday. Returns true if available, false on LoadError.
|
|
239
|
-
def faraday_loaded?
|
|
240
|
-
require "faraday"
|
|
241
|
-
true
|
|
242
|
-
rescue LoadError
|
|
243
|
-
false
|
|
244
|
-
end
|
|
245
|
-
end
|
|
246
|
-
|
|
247
|
-
# Client-level options applied to every request made by a Savon::Client instance.
|
|
248
|
-
# Covers service location, SOAP configuration, logging, response parsing,
|
|
249
|
-
# and transport selection. HTTPI-specific options (proxy, timeouts, SSL, auth)
|
|
250
|
-
# come from HTTPITransportOptions.
|
|
251
73
|
class GlobalOptions < Options
|
|
252
74
|
include SharedOptions
|
|
253
|
-
include HTTPITransportOptions
|
|
254
75
|
|
|
255
76
|
def initialize(options = {})
|
|
256
77
|
@option_type = :global
|
|
78
|
+
|
|
79
|
+
defaults = {
|
|
80
|
+
:encoding => "UTF-8",
|
|
81
|
+
:soap_version => 1,
|
|
82
|
+
:namespaces => {},
|
|
83
|
+
:logger => Logger.new($stdout),
|
|
84
|
+
:log => false,
|
|
85
|
+
:log_headers => true,
|
|
86
|
+
:filters => [],
|
|
87
|
+
:pretty_print_xml => false,
|
|
88
|
+
:raise_errors => true,
|
|
89
|
+
:strip_namespaces => true,
|
|
90
|
+
:delete_namespace_attributes => false,
|
|
91
|
+
:convert_response_tags_to => lambda { |tag| StringUtils.snakecase(tag).to_sym},
|
|
92
|
+
:convert_attributes_to => lambda { |k,v| [k,v] },
|
|
93
|
+
:multipart => false,
|
|
94
|
+
:adapter => nil,
|
|
95
|
+
:use_wsa_headers => false,
|
|
96
|
+
:no_message_tag => false,
|
|
97
|
+
:follow_redirects => false,
|
|
98
|
+
:unwrap => false,
|
|
99
|
+
:host => nil
|
|
100
|
+
}
|
|
101
|
+
|
|
257
102
|
options = defaults.merge(options)
|
|
258
103
|
|
|
259
104
|
# this option is a shortcut on the logger which needs to be set
|
|
@@ -270,7 +115,7 @@ module Savon
|
|
|
270
115
|
@options[:wsdl] = wsdl_address
|
|
271
116
|
end
|
|
272
117
|
|
|
273
|
-
#
|
|
118
|
+
# set different host for actions in WSDL
|
|
274
119
|
def host(host)
|
|
275
120
|
@options[:host] = host
|
|
276
121
|
end
|
|
@@ -295,11 +140,31 @@ module Savon
|
|
|
295
140
|
@options[:namespaces] = namespaces
|
|
296
141
|
end
|
|
297
142
|
|
|
298
|
-
#
|
|
143
|
+
# Proxy server to use for all requests.
|
|
144
|
+
def proxy(proxy)
|
|
145
|
+
@options[:proxy] = proxy unless proxy.nil?
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
# A Hash of HTTP headers.
|
|
299
149
|
def headers(headers)
|
|
300
150
|
@options[:headers] = headers
|
|
301
151
|
end
|
|
302
152
|
|
|
153
|
+
# Open timeout in seconds.
|
|
154
|
+
def open_timeout(open_timeout)
|
|
155
|
+
@options[:open_timeout] = open_timeout
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
# Read timeout in seconds.
|
|
159
|
+
def read_timeout(read_timeout)
|
|
160
|
+
@options[:read_timeout] = read_timeout
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
# Write timeout in seconds.
|
|
164
|
+
def write_timeout(write_timeout)
|
|
165
|
+
@options[:write_timeout] = write_timeout
|
|
166
|
+
end
|
|
167
|
+
|
|
303
168
|
# The encoding to use. Defaults to "UTF-8".
|
|
304
169
|
def encoding(encoding)
|
|
305
170
|
@options[:encoding] = encoding
|
|
@@ -336,19 +201,17 @@ module Savon
|
|
|
336
201
|
|
|
337
202
|
# Whether or not to log.
|
|
338
203
|
def log(log)
|
|
339
|
-
HTTPI.log = log
|
|
340
204
|
@options[:log] = log
|
|
341
205
|
end
|
|
342
206
|
|
|
343
207
|
# The logger to use. Defaults to a Savon::Logger instance.
|
|
344
208
|
def logger(logger)
|
|
345
|
-
HTTPI.logger = logger
|
|
346
209
|
@options[:logger] = logger
|
|
347
210
|
end
|
|
348
211
|
|
|
349
212
|
# Changes the Logger's log level.
|
|
350
213
|
def log_level(level)
|
|
351
|
-
levels = { debug
|
|
214
|
+
levels = { :debug => 0, :info => 1, :warn => 2, :error => 3, :fatal => 4 }
|
|
352
215
|
|
|
353
216
|
unless levels.include? level
|
|
354
217
|
raise ArgumentError, "Invalid log level: #{level.inspect}\n" \
|
|
@@ -358,7 +221,7 @@ module Savon
|
|
|
358
221
|
@options[:logger].level = levels[level]
|
|
359
222
|
end
|
|
360
223
|
|
|
361
|
-
#
|
|
224
|
+
# To log headers or not.
|
|
362
225
|
def log_headers(log_headers)
|
|
363
226
|
@options[:log_headers] = log_headers
|
|
364
227
|
end
|
|
@@ -373,34 +236,104 @@ module Savon
|
|
|
373
236
|
@options[:pretty_print_xml] = pretty_print_xml
|
|
374
237
|
end
|
|
375
238
|
|
|
376
|
-
#
|
|
377
|
-
def
|
|
378
|
-
@options[:
|
|
239
|
+
# Specifies the SSL version to use.
|
|
240
|
+
def ssl_version(version)
|
|
241
|
+
@options[:ssl_version] = version
|
|
379
242
|
end
|
|
380
243
|
|
|
381
|
-
#
|
|
382
|
-
def
|
|
383
|
-
@options[:
|
|
244
|
+
# Specifies the SSL version to use.
|
|
245
|
+
def ssl_min_version(version)
|
|
246
|
+
@options[:ssl_min_version] = version
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
# Specifies the SSL version to use.
|
|
250
|
+
def ssl_max_version(version)
|
|
251
|
+
@options[:ssl_max_version] = version
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
# Whether and how to to verify the connection.
|
|
255
|
+
def ssl_verify_mode(verify_mode)
|
|
256
|
+
@options[:ssl_verify_mode] = verify_mode
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
# Sets the cert key file to use.
|
|
260
|
+
def ssl_cert_key_file(file)
|
|
261
|
+
deprecate('ssl_cert_key_file')
|
|
262
|
+
@options[:ssl_cert_key_file] = file
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
# Sets the cert key to use.
|
|
266
|
+
def ssl_cert_key(key)
|
|
267
|
+
@options[:ssl_cert_key] = key
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
# Sets the cert key password to use.
|
|
271
|
+
def ssl_cert_key_password(password)
|
|
272
|
+
deprecate('ssl_cert_key_password')
|
|
273
|
+
@options[:ssl_cert_key_password] = password
|
|
274
|
+
end
|
|
275
|
+
|
|
276
|
+
# Sets the cert file to use.
|
|
277
|
+
def ssl_cert_file(file)
|
|
278
|
+
deprecate('ssl_cert_file')
|
|
279
|
+
@options[:ssl_cert_file] = file
|
|
280
|
+
end
|
|
281
|
+
|
|
282
|
+
# Sets the cert to use.
|
|
283
|
+
def ssl_cert(cert)
|
|
284
|
+
@options[:ssl_cert] = cert
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
# Sets the ca cert file to use.
|
|
288
|
+
def ssl_ca_cert_file(file)
|
|
289
|
+
@options[:ssl_ca_cert_file] = file
|
|
290
|
+
end
|
|
291
|
+
|
|
292
|
+
# Sets the ca cert to use.
|
|
293
|
+
def ssl_ca_cert(cert)
|
|
294
|
+
deprecate('ssl_ca_cert')
|
|
295
|
+
@options[:ssl_ca_cert] = cert
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
def ssl_ciphers(ciphers)
|
|
299
|
+
deprecate('ssl_ciphers')
|
|
300
|
+
@options[:ssl_ciphers] = ciphers
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
# Sets the ca cert path.
|
|
304
|
+
def ssl_ca_cert_path(path)
|
|
305
|
+
@options[:ssl_ca_cert_path] = path
|
|
384
306
|
end
|
|
385
307
|
|
|
386
|
-
#
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
def empty_tag_value(value)
|
|
390
|
-
@options[:empty_tag_value] = value
|
|
308
|
+
# Sets the ssl cert store.
|
|
309
|
+
def ssl_cert_store(store)
|
|
310
|
+
@options[:ssl_cert_store] = store
|
|
391
311
|
end
|
|
392
312
|
|
|
393
|
-
#
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
@options[:convert_dashes_to_underscores] = convert
|
|
313
|
+
# HTTP basic auth credentials.
|
|
314
|
+
def basic_auth(*credentials)
|
|
315
|
+
@options[:basic_auth] = credentials.flatten
|
|
397
316
|
end
|
|
398
317
|
|
|
399
|
-
#
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
318
|
+
# HTTP digest auth credentials.
|
|
319
|
+
def digest_auth(*credentials)
|
|
320
|
+
deprecate('digest_auth')
|
|
321
|
+
@options[:digest_auth] = credentials.flatten
|
|
322
|
+
end
|
|
323
|
+
|
|
324
|
+
# NTLM auth credentials.
|
|
325
|
+
def ntlm(*credentials)
|
|
326
|
+
@options[:ntlm] = credentials.flatten
|
|
327
|
+
end
|
|
328
|
+
|
|
329
|
+
# Instruct Nori whether to strip namespaces from XML nodes.
|
|
330
|
+
def strip_namespaces(strip_namespaces)
|
|
331
|
+
@options[:strip_namespaces] = strip_namespaces
|
|
332
|
+
end
|
|
333
|
+
|
|
334
|
+
# Instruct Nori whether to delete namespace attributes from XML nodes.
|
|
335
|
+
def delete_namespace_attributes(delete_namespace_attributes)
|
|
336
|
+
@options[:delete_namespace_attributes] = delete_namespace_attributes
|
|
404
337
|
end
|
|
405
338
|
|
|
406
339
|
# Tell Gyoku how to convert Hash key Symbols to XML tags.
|
|
@@ -409,87 +342,51 @@ module Savon
|
|
|
409
342
|
@options[:convert_request_keys_to] = converter
|
|
410
343
|
end
|
|
411
344
|
|
|
412
|
-
# Tell Gyoku to unwrap Array of Hashes
|
|
413
|
-
# Accepts a boolean,
|
|
345
|
+
# Tell Gyoku to unwrap Array of Hashes
|
|
346
|
+
# Accepts a boolean, default to false
|
|
414
347
|
def unwrap(unwrap)
|
|
415
348
|
@options[:unwrap] = unwrap
|
|
416
349
|
end
|
|
417
350
|
|
|
418
351
|
# Tell Nori how to convert XML tags from the SOAP response into Hash keys.
|
|
419
352
|
# Accepts a lambda or a block which receives an XML tag and returns a Hash key.
|
|
420
|
-
# Defaults to
|
|
353
|
+
# Defaults to convert tags to snakecase Symbols.
|
|
421
354
|
def convert_response_tags_to(converter = nil, &block)
|
|
422
355
|
@options[:convert_response_tags_to] = block || converter
|
|
423
356
|
end
|
|
424
357
|
|
|
425
358
|
# Tell Nori how to convert XML attributes on tags from the SOAP response into Hash keys.
|
|
426
359
|
# Accepts a lambda or a block which receives an XML tag and returns a Hash key.
|
|
427
|
-
# Defaults to doing nothing
|
|
360
|
+
# Defaults to doing nothing
|
|
428
361
|
def convert_attributes_to(converter = nil, &block)
|
|
429
362
|
@options[:convert_attributes_to] = block || converter
|
|
430
363
|
end
|
|
431
364
|
|
|
432
365
|
# Instruct Savon to create a multipart response if available.
|
|
433
366
|
def multipart(multipart)
|
|
434
|
-
if multipart
|
|
435
|
-
warn "The global :multipart option has been a no-op since v2.13.0. " \
|
|
436
|
-
"Savon detects whether the response is multipart by checking if the " \
|
|
437
|
-
"response Content-Type header contains 'multipart'. You can remove" \
|
|
438
|
-
"this option from your code to make this warning disappear.", uplevel: 1
|
|
439
|
-
end
|
|
440
367
|
@options[:multipart] = multipart
|
|
441
368
|
end
|
|
442
369
|
|
|
370
|
+
# Instruct Savon what Faraday adapter it should use instead of default
|
|
371
|
+
def adapter(adapter)
|
|
372
|
+
@options[:adapter] = adapter
|
|
373
|
+
end
|
|
374
|
+
|
|
443
375
|
# Enable inclusion of WS-Addressing headers.
|
|
444
376
|
def use_wsa_headers(use)
|
|
445
377
|
@options[:use_wsa_headers] = use
|
|
446
378
|
end
|
|
447
379
|
|
|
448
|
-
# Suppress the message tag wrapper around the SOAP body.
|
|
449
380
|
def no_message_tag(bool)
|
|
450
381
|
@options[:no_message_tag] = bool
|
|
451
382
|
end
|
|
452
383
|
|
|
453
|
-
#
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
def transport(transport)
|
|
457
|
-
@options[:transport] = transport
|
|
458
|
-
end
|
|
459
|
-
|
|
460
|
-
private
|
|
461
|
-
|
|
462
|
-
# The default value for every global option.
|
|
463
|
-
def defaults
|
|
464
|
-
HTTPITransportOptions::TRANSPORT_DEFAULTS.merge(
|
|
465
|
-
encoding: "UTF-8",
|
|
466
|
-
soap_version: 1,
|
|
467
|
-
namespaces: {},
|
|
468
|
-
logger: Logger.new($stdout),
|
|
469
|
-
log: false,
|
|
470
|
-
log_headers: true,
|
|
471
|
-
filters: [],
|
|
472
|
-
pretty_print_xml: false,
|
|
473
|
-
raise_errors: true,
|
|
474
|
-
strip_namespaces: true,
|
|
475
|
-
delete_namespace_attributes: false,
|
|
476
|
-
empty_tag_value: nil,
|
|
477
|
-
convert_dashes_to_underscores: true,
|
|
478
|
-
scrub_xml: true,
|
|
479
|
-
convert_response_tags_to: ->(tag) { StringUtils.snakecase(tag).to_sym },
|
|
480
|
-
convert_attributes_to: ->(k, v) { [k, v] },
|
|
481
|
-
multipart: false,
|
|
482
|
-
use_wsa_headers: false,
|
|
483
|
-
no_message_tag: false,
|
|
484
|
-
unwrap: false,
|
|
485
|
-
host: nil,
|
|
486
|
-
transport: :httpi
|
|
487
|
-
)
|
|
384
|
+
# Instruct requests to follow HTTP redirects.
|
|
385
|
+
def follow_redirects(follow_redirects)
|
|
386
|
+
@options[:follow_redirects] = follow_redirects
|
|
488
387
|
end
|
|
489
388
|
end
|
|
490
389
|
|
|
491
|
-
# Per-request options passed to client.call.
|
|
492
|
-
# Overrides or extends the matching GlobalOptions for a single SOAP operation.
|
|
493
390
|
class LocalOptions < Options
|
|
494
391
|
include SharedOptions
|
|
495
392
|
|
|
@@ -497,10 +394,10 @@ module Savon
|
|
|
497
394
|
@option_type = :local
|
|
498
395
|
|
|
499
396
|
defaults = {
|
|
500
|
-
advanced_typecasting
|
|
501
|
-
response_parser
|
|
502
|
-
multipart
|
|
503
|
-
|
|
397
|
+
:advanced_typecasting => true,
|
|
398
|
+
:response_parser => :nokogiri,
|
|
399
|
+
:multipart => false,
|
|
400
|
+
:body => false
|
|
504
401
|
}
|
|
505
402
|
|
|
506
403
|
super defaults.merge(options)
|
|
@@ -533,10 +430,7 @@ module Savon
|
|
|
533
430
|
#
|
|
534
431
|
# should pass an Array or a Hash; items should be path strings or
|
|
535
432
|
# { filename: 'file.name', content: 'content' } objects
|
|
536
|
-
# The Content-ID in multipart message sections will be the filename or the key if Hash is given
|
|
537
|
-
# An attachment hash may set content_id: to use a different Content-ID, e.g. when the
|
|
538
|
-
# filename holds characters that are invalid in a header, or when two attachments
|
|
539
|
-
# share a filename. Without content_id:, the Content-ID defaults to the filename or key.
|
|
433
|
+
# The Content-ID in multipart message sections will be the filename or the key if Hash is given
|
|
540
434
|
#
|
|
541
435
|
# usage examples:
|
|
542
436
|
#
|
|
@@ -566,23 +460,16 @@ module Savon
|
|
|
566
460
|
@options[:attachments] = attachments
|
|
567
461
|
end
|
|
568
462
|
|
|
569
|
-
# Emit outbound MTOM/XOP request framing for attachments.
|
|
570
|
-
#
|
|
571
|
-
# This is a low-level framing option. Savon does not rewrite normal base64 XML
|
|
572
|
-
# into XOP or process inbound MTOM responses. Callers must provide XML with
|
|
573
|
-
# xop:Include href="cid:..." references and matching attachment Content-IDs.
|
|
574
|
-
# It has no effect without attachments. An attachment hash may set
|
|
575
|
-
# content_id: to choose its Content-ID independently of its filename.
|
|
576
|
-
def mtom(mtom)
|
|
577
|
-
@options[:mtom] = mtom
|
|
578
|
-
end
|
|
579
|
-
|
|
580
463
|
# Value of the SOAPAction HTTP header.
|
|
581
464
|
def soap_action(soap_action)
|
|
582
465
|
@options[:soap_action] = soap_action
|
|
583
466
|
end
|
|
584
467
|
|
|
585
|
-
# Cookies to be used for the next request
|
|
468
|
+
# Cookies to be used for the next request
|
|
469
|
+
# @param [Hash] cookies cookies associated to nil will be appended as array cookies, if you need a cookie equal to
|
|
470
|
+
# and empty string, set it to ""
|
|
471
|
+
# @example cookies({accept: 'application/json', some-cookie: 'foo', "empty-cookie": "", HttpOnly: nil})
|
|
472
|
+
# # => "accept=application/json; some-cookie=foo; empty-cookie=; HttpOnly"
|
|
586
473
|
def cookies(cookies)
|
|
587
474
|
@options[:cookies] = cookies
|
|
588
475
|
end
|
|
@@ -604,18 +491,15 @@ module Savon
|
|
|
604
491
|
|
|
605
492
|
# Instruct Savon to create a multipart response if available.
|
|
606
493
|
def multipart(multipart)
|
|
607
|
-
if multipart
|
|
608
|
-
warn "The local :multipart option has been a no-op since v2.13.0. " \
|
|
609
|
-
"Savon detects whether the response is multipart by checking if the " \
|
|
610
|
-
"response Content-Type header contains 'multipart'. You can remove" \
|
|
611
|
-
"this option from your code to make this warning disappear.", uplevel: 1
|
|
612
|
-
end
|
|
613
494
|
@options[:multipart] = multipart
|
|
614
495
|
end
|
|
615
496
|
|
|
616
|
-
# Per-request HTTP headers. Merged with global headers for each request.
|
|
617
497
|
def headers(headers)
|
|
618
498
|
@options[:headers] = headers
|
|
619
499
|
end
|
|
500
|
+
|
|
501
|
+
def body(body)
|
|
502
|
+
@options[:body] = body
|
|
503
|
+
end
|
|
620
504
|
end
|
|
621
505
|
end
|