savon 2.5.0 → 2.5.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 50130e634559c3c2470b09405d608fb86887e1d5
4
- data.tar.gz: 80f641ad66bf740cd6d90beda49830c544e988b0
3
+ metadata.gz: 203ea0a3b371b474e308510c481c6e47f91b3139
4
+ data.tar.gz: 65db092bfb28fdf4865f1749596cbc0c88d00136
5
5
  SHA512:
6
- metadata.gz: 4a791ac4059d5372ba758b334d066fd18af294ff42776b3f752e0e3ba0ee880d69ccf8cbeb5e9a7a9ce702d22dc45b20f1f34fc32143cc87fd59ca6af0d65e82
7
- data.tar.gz: a81490063101948bee370664696ef1b61192992ef98477959fd04c2b73e0f7b1ffb5794cade623a0c7e483506a772be3c64175396fb17a8986308ff61da1ef55
6
+ metadata.gz: 5aff0b2e3c5a7fa75ce5871cc5af0d86c5e7da239f98636458ec963ddb91bbcb8fa9808b59adee5df9c06427ae202fe3ca8e0c8674fcfdfd6fa09351cb788601
7
+ data.tar.gz: ea8d384e0ea58276ddb33fcfd499d0876f12cc46dec42ebb59598f09f5ff83244d0e35d1e60162cdb11620b3b1aa9230608614b32e897e13742cf31d6b0787e3
@@ -5,10 +5,7 @@ rvm:
5
5
  - 1.9.2
6
6
  - 1.9.3
7
7
  - 2.0
8
- - jruby-19mode
9
- - rbx
8
+ - jruby
9
+ - rbx-2
10
10
  notifications:
11
11
  irc: "irc.freenode.org#savon"
12
- matrix:
13
- allow_failures:
14
- - rvm: jruby-19mode
@@ -1,9 +1,12 @@
1
1
  # 2.5.0 (2014-05-03)
2
2
 
3
+ * Feature: [#573](https://github.com/savonrb/savon/pull/573) Add an `all_operations` method to `Savon::Model` that automatically adds all available operations to the model.
4
+
3
5
  * Feature: [#566](https://github.com/savonrb/savon/pull/566) Allow specifying HTTPI adapter per client.
4
6
 
5
7
  ```ruby
6
8
  curb_client = Savon.client(wsdl: "http://example.com/service.wsdl", adapter: :curb)
9
+
7
10
  http_client = Savon.client(wsdl: "http://example.com/service.wsdl", adapter: :httpclient)
8
11
  ```
9
12
 
data/Gemfile CHANGED
@@ -5,6 +5,7 @@ gem "httpclient", "~> 2.3.4"
5
5
 
6
6
  gem "simplecov", :require => false
7
7
  gem "coveralls", :require => false
8
+ gem "uuid"
8
9
 
9
10
  platform :rbx do
10
11
  gem 'json'
@@ -17,6 +17,8 @@ module Savon
17
17
  2 => "http://www.w3.org/2003/05/soap-envelope"
18
18
  }
19
19
 
20
+ WSA_NAMESPACE = "http://www.w3.org/2005/08/addressing"
21
+
20
22
  def initialize(operation_name, wsdl, globals, locals)
21
23
  @operation_name = operation_name
22
24
 
@@ -32,15 +34,25 @@ module Savon
32
34
  Nokogiri.XML(to_s).to_xml(:indent => 2)
33
35
  end
34
36
 
35
- def to_s
36
- return @locals[:xml] if @locals.include? :xml
37
-
37
+ def build_document
38
38
  tag(builder, :Envelope, namespaces_with_globals) do |xml|
39
- tag(xml, :Header) { xml << header.to_s } unless header.empty?
40
- tag(xml, :Body) { xml.tag!(*namespaced_message_tag) { xml << message.to_s } }
39
+ tag(xml, :Header, header_attributes) { xml << header.to_s } unless header.empty?
40
+ tag(xml, :Body, body_attributes) { xml.tag!(*namespaced_message_tag) { xml << message.to_s } }
41
41
  end
42
42
  end
43
43
 
44
+ def header_attributes
45
+ { 'xmlns:wsa' => WSA_NAMESPACE } if @globals[:use_wsa_headers]
46
+ end
47
+
48
+ def body_attributes
49
+ end
50
+
51
+ def to_s
52
+ return @locals[:xml] if @locals.include? :xml
53
+ build_document
54
+ end
55
+
44
56
  private
45
57
 
46
58
  def convert_type_definitions_to_hash
@@ -1,5 +1,6 @@
1
1
  require "akami"
2
2
  require "gyoku"
3
+ require "uuid"
3
4
 
4
5
  module Savon
5
6
  class Header
@@ -13,6 +14,9 @@ module Savon
13
14
  @global_header = globals[:soap_header]
14
15
  @local_header = locals[:soap_header]
15
16
 
17
+ @globals = globals
18
+ @locals = locals
19
+
16
20
  @header = build
17
21
  end
18
22
 
@@ -30,7 +34,7 @@ module Savon
30
34
  private
31
35
 
32
36
  def build
33
- build_header + build_wsse_header
37
+ build_header + build_wsa_header + build_wsse_header
34
38
  end
35
39
 
36
40
  def build_header
@@ -51,6 +55,15 @@ module Savon
51
55
  wsse_header.respond_to?(:to_xml) ? wsse_header.to_xml : ""
52
56
  end
53
57
 
58
+ def build_wsa_header
59
+ return '' unless @globals[:use_wsa_headers]
60
+ convert_to_xml({
61
+ 'wsa:Action' => @locals[:soap_action],
62
+ 'wsa:To' => @globals[:endpoint],
63
+ 'wsa:MessageID' => "urn:uuid:#{UUID.new.generate}"
64
+ })
65
+ end
66
+
54
67
  def convert_to_xml(hash_or_string)
55
68
  if hash_or_string.kind_of? Hash
56
69
  Gyoku.xml(hash_or_string, gyoku_options)
@@ -19,6 +19,10 @@ module Savon
19
19
  end
20
20
  end
21
21
 
22
+ def all_operations
23
+ operations(*client.operations)
24
+ end
25
+
22
26
  private
23
27
 
24
28
  # Defines a class-level SOAP operation.
@@ -87,6 +87,9 @@ module Savon
87
87
  end
88
88
 
89
89
  def build_request(builder)
90
+ @locals[:soap_action] ||= soap_action
91
+ @globals[:endpoint] ||= endpoint
92
+
90
93
  request = SOAPRequest.new(@globals).build(
91
94
  :soap_action => soap_action,
92
95
  :cookies => @locals[:cookies]
@@ -57,6 +57,7 @@ module Savon
57
57
  :convert_attributes_to => lambda { |k,v| [k,v] },
58
58
  :multipart => false,
59
59
  :adapter => nil,
60
+ :use_wsa_headers => false,
60
61
  }
61
62
 
62
63
  options = defaults.merge(options)
@@ -271,6 +272,11 @@ module Savon
271
272
  def adapter(adapter)
272
273
  @options[:adapter] = adapter
273
274
  end
275
+
276
+ # Enable inclusion of WS-Addressing headers.
277
+ def use_wsa_headers(use)
278
+ @options[:use_wsa_headers] = use
279
+ end
274
280
  end
275
281
 
276
282
  class LocalOptions < Options
@@ -1,3 +1,3 @@
1
1
  module Savon
2
- VERSION = '2.5.0'
2
+ VERSION = '2.5.1'
3
3
  end
@@ -21,6 +21,7 @@ Gem::Specification.new do |s|
21
21
  s.add_dependency "wasabi", "~> 3.3.0"
22
22
  s.add_dependency "akami", "~> 1.2.0"
23
23
  s.add_dependency "gyoku", "~> 1.1.0"
24
+ s.add_dependency "uuid", "~> 2.3.7"
24
25
 
25
26
  s.add_dependency "builder", ">= 2.1.2"
26
27
 
@@ -151,4 +151,32 @@ describe Savon::Model do
151
151
  supermodel.authenticate(:message => { :username => "luke", :password => "secret" })
152
152
  end
153
153
 
154
+ describe ".all_operations" do
155
+ it "should call operations with all available client operations" do
156
+ model = Class.new {
157
+ extend Savon::Model
158
+
159
+ client :wsdl => Fixture.wsdl(:taxcloud)
160
+ all_operations
161
+ }
162
+
163
+ [:verify_address,
164
+ :lookup_for_date,
165
+ :lookup,
166
+ :authorized,
167
+ :authorized_with_capture,
168
+ :captured,
169
+ :returned,
170
+ :get_tic_groups,
171
+ :get_ti_cs,
172
+ :get_ti_cs_by_group,
173
+ :add_exempt_certificate,
174
+ :delete_exempt_certificate,
175
+ :get_exempt_certificates].each do |method|
176
+ expect(model).to respond_to(method)
177
+ end
178
+ end
179
+
180
+ end
181
+
154
182
  end
@@ -86,7 +86,8 @@ describe "Options" do
86
86
  expect { client.call(:authenticate) }.to raise_error { |error|
87
87
  host_unreachable = error.kind_of? Errno::EHOSTUNREACH
88
88
  net_unreachable = error.kind_of? Errno::ENETUNREACH
89
- if host_unreachable || net_unreachable
89
+ socket_err = error.kind_of? SocketError
90
+ if host_unreachable || net_unreachable || socket_err
90
91
  warn "Warning: looks like your network may be down?!\n" +
91
92
  "-> skipping spec at #{__FILE__}:#{__LINE__}"
92
93
  else
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: savon
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0
4
+ version: 2.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Harrington
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-04 00:00:00.000000000 Z
11
+ date: 2014-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nori
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ~>
81
81
  - !ruby/object:Gem::Version
82
82
  version: 1.1.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: uuid
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: 2.3.7
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: 2.3.7
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: builder
85
99
  requirement: !ruby/object:Gem::Requirement