savon 2.0.0 → 2.0.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.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 2.0.1 (2012-12-19)
2
+
3
+ * Fix [#342](https://github.com/savonrb/savon/issues/342) fixes an issue where namespaces could
4
+ not be resolved if the actual operation name to call did not match the operation name passed
5
+ to the client's `#call` method. For example: `:get_stations` for a `getStations` operation.
6
+
1
7
  ## 2.0.0 (2012-12-18)
2
8
 
3
9
  * Read about all the changes in the [updated documentation](http://savonrb.com/version2.html).
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- Savon [![Build Status](https://secure.travis-ci.org/savonrb/savon.png?branch=version2)](http://travis-ci.org/savonrb/savon)
1
+ Savon [![Build Status](https://secure.travis-ci.org/savonrb/savon.png)](http://travis-ci.org/savonrb/savon)
2
2
  =====
3
3
 
4
4
  Heavy metal SOAP client
@@ -6,15 +6,16 @@ Heavy metal SOAP client
6
6
  [Documentation](http://savonrb.com) | [RDoc](http://rubydoc.info/gems/savon) |
7
7
  [Mailing list](https://groups.google.com/forum/#!forum/savonrb) | [Twitter](http://twitter.com/savonrb)
8
8
 
9
- Version 2
10
- ---------
11
9
 
12
- Savon 2.0 is almost feature-complete and I would really appreciate your feedback!
13
- To get started, add the following line to your Gemfile:
10
+ Installation
11
+ ------------
12
+
13
+ Savon is available through [Rubygems](http://rubygems.org/gems/savon) and can be installed via:
14
14
 
15
- ``` ruby
16
- gem "savon", github: "savonrb/savon", branch: "version2"
17
15
  ```
16
+ $ gem install savon
17
+ ```
18
+
18
19
 
19
20
  Introduction
20
21
  ------------
@@ -37,7 +38,8 @@ response.body
37
38
  # => { :get_user_response => { :first_name => "The", :last_name => "Hoff" } }
38
39
  ```
39
40
 
41
+
40
42
  Documentation
41
43
  -------------
42
44
 
43
- Continue reading at [savonrb.com](http://savonrb.com/version2.html)
45
+ Continue reading at [savonrb.com](http://savonrb.com)
data/lib/savon/message.rb CHANGED
@@ -19,7 +19,8 @@ module Savon
19
19
  return @message.to_s unless @message.kind_of? Hash
20
20
 
21
21
  if @element_form_default == :qualified
22
- @message = QualifiedMessage.new(@types, @used_namespaces, @request_key_converter).to_hash(@message, [@operation_name.to_s])
22
+ translated_operation_name = Gyoku.xml_tag(@operation_name, :key_converter => @key_converter).to_s
23
+ @message = QualifiedMessage.new(@types, @used_namespaces, @request_key_converter).to_hash(@message, [translated_operation_name])
23
24
  end
24
25
 
25
26
  gyoku_options = {
@@ -15,12 +15,12 @@ module Savon
15
15
  return hash.to_s unless hash.kind_of? Hash
16
16
 
17
17
  hash.inject({}) do |newhash, (key, value)|
18
- camelcased_key = Gyoku.xml_tag(key, :key_converter => @key_converter).to_s
19
- newpath = path + [camelcased_key]
18
+ translated_key = Gyoku.xml_tag(key, :key_converter => @key_converter).to_s
19
+ newpath = path + [translated_key]
20
20
 
21
21
  if @used_namespaces[newpath]
22
22
  newhash.merge(
23
- "#{@used_namespaces[newpath]}:#{camelcased_key}" =>
23
+ "#{@used_namespaces[newpath]}:#{translated_key}" =>
24
24
  add_namespaces_to_body(value, @types[newpath] ? [@types[newpath]] : newpath)
25
25
  )
26
26
  else
data/lib/savon/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Savon
2
2
 
3
- VERSION = "2.0.0"
3
+ VERSION = "2.0.1"
4
4
 
5
5
  end
@@ -0,0 +1,32 @@
1
+ require "spec_helper"
2
+
3
+ describe "Email example" do
4
+
5
+ it "passes Strings as they are" do
6
+ client = Savon.client(
7
+ # The WSDL document provided by the service.
8
+ :wsdl => "http://ws.cdyne.com/emailverify/Emailvernotestemail.asmx?wsdl",
9
+
10
+ # Lower timeouts so these specs don't take forever when the service is not available.
11
+ :open_timeout => 10,
12
+ :read_timeout => 10,
13
+
14
+ # Disable logging for cleaner spec output.
15
+ :log => false
16
+ )
17
+
18
+ response = client.call(:verify_email, :message => { :email => "soap@example.com", "LicenseKey" => "?" })
19
+
20
+ response_text = response.body[:verify_email_response][:verify_email_result][:response_text]
21
+
22
+ if response_text == "Current license key only allows so many checks"
23
+ # Fallback to not fail the specs when the service's API limit is reached,
24
+ # but to mark the spec as pending instead.
25
+ pending "API limit exceeded"
26
+ else
27
+ # The expected result. We unfortunately don't have a license key for this service.
28
+ response_text.should == "Email Domain Not Found"
29
+ end
30
+ end
31
+
32
+ end
@@ -0,0 +1,40 @@
1
+ require "spec_helper"
2
+
3
+ describe "RATP example" do
4
+
5
+ it "retrieves information about a specific station" do
6
+ client = Savon.client do
7
+ # The WSDL document provided by the service.
8
+ wsdl "http://www.ratp.fr/wsiv/services/Wsiv?wsdl"
9
+
10
+ # Lower timeouts so these specs don't take forever when the service is not available.
11
+ open_timeout 10
12
+ read_timeout 10
13
+
14
+ # Disable logging for cleaner spec output.
15
+ log false
16
+ end
17
+
18
+ response = client.call(:get_stations) do
19
+ # For the corrent values to pass for :from_unit and :to_unit, I searched the WSDL for
20
+ # the "FromUnit" type which is a "TemperatureUnit" enumeration that looks like this:
21
+ #
22
+ # <s:simpleType name="TemperatureUnit">
23
+ # <s:restriction base="s:string">
24
+ # <s:enumeration value="degreeCelsius"/>
25
+ # <s:enumeration value="degreeFahrenheit"/>
26
+ # <s:enumeration value="degreeRankine"/>
27
+ # <s:enumeration value="degreeReaumur"/>
28
+ # <s:enumeration value="kelvin"/>
29
+ # </s:restriction>
30
+ # </s:simpleType>
31
+ #
32
+ # Support for XS schema types needs to be improved.
33
+ message(:station => { :id => 1975 }, :limit => 1)
34
+ end
35
+
36
+ station_name = response.body[:get_stations_response][:return][:stations][:name]
37
+ expect(station_name).to eq("Cite")
38
+ end
39
+
40
+ end
@@ -0,0 +1,28 @@
1
+ require "spec_helper"
2
+
3
+ describe "Stockquote example" do
4
+
5
+ it "returns the result in a CDATA tag" do
6
+ client = Savon.client(
7
+ # The WSDL document provided by the service.
8
+ :wsdl => "http://www.webservicex.net/stockquote.asmx?WSDL",
9
+
10
+ # Lower timeouts so these specs don't take forever when the service is not available.
11
+ :open_timeout => 10,
12
+ :read_timeout => 10,
13
+
14
+ # Disable logging for cleaner spec output.
15
+ :log => false
16
+ )
17
+
18
+ response = client.call(:get_quote, :message => { :symbol => "AAPL" })
19
+
20
+ cdata = response.body[:get_quote_response][:get_quote_result]
21
+
22
+ nori_options = { :convert_tags_to => lambda { |tag| tag.snakecase.to_sym } }
23
+ result = Nori.new(nori_options).parse(cdata)
24
+
25
+ result[:stock_quotes][:stock][:symbol].should == "AAPL"
26
+ end
27
+
28
+ end
@@ -0,0 +1,46 @@
1
+ require "spec_helper"
2
+
3
+ describe "Temperature example" do
4
+
5
+ it "converts 30 degrees celsius to 86 degrees fahrenheit" do
6
+ client = Savon.client do
7
+ # The WSDL document provided by the service.
8
+ wsdl "http://www.webservicex.net/ConvertTemperature.asmx?WSDL"
9
+
10
+ # Needed because (up until now), Savon doesn't match XS types to Hash keys,
11
+ # but defaults to convert Hash message Symbols (like :from_unit) to lowerCamelCase.
12
+ # The service expects these to be CamelCase instead. Look at Savon's log output
13
+ # and compare it with an example request generated by soapUI.
14
+ convert_request_keys_to :camelcase
15
+
16
+ # Lower timeouts so these specs don't take forever when the service is not available.
17
+ open_timeout 10
18
+ read_timeout 10
19
+
20
+ # Disable logging for cleaner spec output.
21
+ log false
22
+ end
23
+
24
+ response = client.call(:convert_temp) do
25
+ # For the corrent values to pass for :from_unit and :to_unit, I searched the WSDL for
26
+ # the "FromUnit" type which is a "TemperatureUnit" enumeration that looks like this:
27
+ #
28
+ # <s:simpleType name="TemperatureUnit">
29
+ # <s:restriction base="s:string">
30
+ # <s:enumeration value="degreeCelsius"/>
31
+ # <s:enumeration value="degreeFahrenheit"/>
32
+ # <s:enumeration value="degreeRankine"/>
33
+ # <s:enumeration value="degreeReaumur"/>
34
+ # <s:enumeration value="kelvin"/>
35
+ # </s:restriction>
36
+ # </s:simpleType>
37
+ #
38
+ # Support for XS schema types needs to be improved.
39
+ message(:temperature => 30, :from_unit => "degreeCelsius", :to_unit => "degreeFahrenheit")
40
+ end
41
+
42
+ fahrenheit = response.body[:convert_temp_response][:convert_temp_result]
43
+ expect(fahrenheit).to eq("86")
44
+ end
45
+
46
+ end
@@ -0,0 +1,42 @@
1
+ require "spec_helper"
2
+
3
+ describe "ZIP code example" do
4
+
5
+ it "supports threads making requests simultaneously" do
6
+ client = Savon.client(
7
+ # The WSDL document provided by the service.
8
+ :wsdl => "http://www.thomas-bayer.com/axis2/services/BLZService?wsdl",
9
+
10
+ # Lower timeouts so these specs don't take forever when the service is not available.
11
+ :open_timeout => 10,
12
+ :read_timeout => 10,
13
+
14
+ # Disable logging for cleaner spec output.
15
+ :log => false
16
+ )
17
+
18
+ mutex = Mutex.new
19
+
20
+ request_data = [70070010, 24050110, 20050550]
21
+ threads_waiting = request_data.size
22
+
23
+ threads = request_data.map do |blz|
24
+ thread = Thread.new do
25
+ response = client.call :get_bank, :message => { :blz => blz }
26
+ Thread.current[:value] = response.body[:get_bank_response][:details]
27
+ mutex.synchronize { threads_waiting -= 1 }
28
+ end
29
+
30
+ thread.abort_on_exception = true
31
+ thread
32
+ end
33
+
34
+ sleep(1) until threads_waiting == 0
35
+
36
+ threads.each(&:kill)
37
+ values = threads.map { |thr| thr[:value] }.compact
38
+
39
+ values.uniq.size.should == values.size
40
+ end
41
+
42
+ end
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: savon
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-18 00:00:00.000000000 Z
12
+ date: 2012-12-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nori
@@ -253,10 +253,13 @@ files:
253
253
  - spec/fixtures/wsdl/multiple_namespaces.xml
254
254
  - spec/fixtures/wsdl/multiple_types.xml
255
255
  - spec/fixtures/wsdl/taxcloud.xml
256
- - spec/integration/options_spec.rb
257
- - spec/integration/request_spec.rb
256
+ - spec/integration/email_example_spec.rb
257
+ - spec/integration/ratp_example_spec.rb
258
+ - spec/integration/stockquote_example_spec.rb
258
259
  - spec/integration/support/application.rb
259
260
  - spec/integration/support/server.rb
261
+ - spec/integration/temperature_example_spec.rb
262
+ - spec/integration/zipcode_example_spec.rb
260
263
  - spec/savon/builder_spec.rb
261
264
  - spec/savon/client_spec.rb
262
265
  - spec/savon/core_ext/string_spec.rb
@@ -266,6 +269,7 @@ files:
266
269
  - spec/savon/model_spec.rb
267
270
  - spec/savon/observers_spec.rb
268
271
  - spec/savon/operation_spec.rb
272
+ - spec/savon/options_spec.rb
269
273
  - spec/savon/request_spec.rb
270
274
  - spec/savon/response_spec.rb
271
275
  - spec/savon/soap_fault_spec.rb
@@ -286,7 +290,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
286
290
  version: '0'
287
291
  segments:
288
292
  - 0
289
- hash: -4031726402379507170
293
+ hash: 2358911871960345880
290
294
  required_rubygems_version: !ruby/object:Gem::Requirement
291
295
  none: false
292
296
  requirements:
@@ -295,7 +299,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
295
299
  version: '0'
296
300
  segments:
297
301
  - 0
298
- hash: -4031726402379507170
302
+ hash: 2358911871960345880
299
303
  requirements: []
300
304
  rubyforge_project: savon
301
305
  rubygems_version: 1.8.24
@@ -1,76 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe "Requests" do
4
-
5
- subject(:client) {
6
- Savon.client(:wsdl => service_endpoint, :open_timeout => 10, :read_timeout => 10,
7
- :raise_errors => false, :log => false)
8
- }
9
-
10
- context "stockquote" do
11
- let(:service_endpoint) { "http://www.webservicex.net/stockquote.asmx?WSDL" }
12
-
13
- it "returns the result in a CDATA tag" do
14
- response = client.call(:get_quote, :message => { :symbol => "AAPL" })
15
-
16
- cdata = response.body[:get_quote_response][:get_quote_result]
17
-
18
- nori_options = { :convert_tags_to => lambda { |tag| tag.snakecase.to_sym } }
19
- result = Nori.new(nori_options).parse(cdata)
20
-
21
- result[:stock_quotes][:stock][:symbol].should == "AAPL"
22
- end
23
- end
24
-
25
- context "email" do
26
- let(:service_endpoint) { "http://ws.cdyne.com/emailverify/Emailvernotestemail.asmx?wsdl" }
27
-
28
- it "passes Strings as they are" do
29
- response = client.call(:verify_email, :message => { :email => "soap@example.com", "LicenseKey" => "?" })
30
-
31
- response_text = response.body[:verify_email_response][:verify_email_result][:response_text]
32
-
33
- if response_text == "Current license key only allows so many checks"
34
- pending "API limit exceeded"
35
- else
36
- response_text.should == "Email Domain Not Found"
37
- end
38
- end
39
- end
40
-
41
- context "zip code" do
42
- let(:service_endpoint) { "http://www.thomas-bayer.com/axis2/services/BLZService?wsdl" }
43
-
44
- it "supports threads making requests simultaneously" do
45
- mutex = Mutex.new
46
-
47
- request_data = [70070010, 24050110, 20050550]
48
- threads_waiting = request_data.size
49
-
50
- threads = request_data.map do |blz|
51
- thread = Thread.new do
52
- response = client.call :get_bank, :message => { :blz => blz }
53
- Thread.current[:value] = response.body[:get_bank_response][:details]
54
- mutex.synchronize { threads_waiting -= 1 }
55
- end
56
-
57
- thread.abort_on_exception = true
58
- thread
59
- end
60
-
61
- sleep(1) until threads_waiting == 0
62
-
63
- threads.each(&:kill)
64
- values = threads.map { |thr| thr[:value] }.compact
65
-
66
- values.uniq.size.should == values.size
67
- end
68
- end
69
-
70
- context "redirectes" do
71
- it "follows 301 redirects"
72
- it "follows 302 redirects"
73
- it "follows 307 redirects"
74
- end
75
-
76
- end