rubiii-savon 0.2.3 → 0.2.4
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/Rakefile +3 -3
- data/VERSION +1 -1
- data/lib/savon/service.rb +20 -5
- data/spec/savon/service_spec.rb +10 -3
- metadata +8 -8
data/Rakefile
CHANGED
@@ -23,9 +23,9 @@ begin
|
|
23
23
|
Jeweler::Tasks.new do |spec|
|
24
24
|
spec.name = "savon"
|
25
25
|
spec.author = "Daniel Harrington"
|
26
|
-
spec.email = "me@
|
26
|
+
spec.email = "me@rubiii.com"
|
27
27
|
spec.homepage = "http://github.com/rubiii/savon"
|
28
|
-
spec.summary = "SOAP client library to enjoy
|
28
|
+
spec.summary = "SOAP client library to enjoy"
|
29
29
|
spec.description = spec.summary
|
30
30
|
|
31
31
|
spec.files = FileList["[A-Z]*", "{lib,spec}/**/*.{rb,xml}"]
|
@@ -38,7 +38,7 @@ begin
|
|
38
38
|
]
|
39
39
|
|
40
40
|
spec.add_runtime_dependency("hpricot", "0.8.241")
|
41
|
-
spec.add_runtime_dependency("rubiii-apricoteatsgorilla", "0.5.
|
41
|
+
spec.add_runtime_dependency("rubiii-apricoteatsgorilla", "0.5.6")
|
42
42
|
|
43
43
|
spec.add_development_dependency("rspec", ">= 1.2.8")
|
44
44
|
spec.add_development_dependency("rr", ">= 0.10.0")
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.4
|
data/lib/savon/service.rb
CHANGED
@@ -12,10 +12,18 @@ module Savon
|
|
12
12
|
# response = proxy.find_user_by_id(:id => 123)
|
13
13
|
class Service
|
14
14
|
|
15
|
-
#
|
16
|
-
|
15
|
+
# Supported SOAP versions.
|
16
|
+
SOAPVersions = [1, 2]
|
17
|
+
|
18
|
+
# Content-Types by SOAP version.
|
19
|
+
ContentType = { 1 => "text/xml", 2 => "application/soap+xml" }
|
20
|
+
|
21
|
+
# Initializer expects an +endpoint+ URI and takes an optional SOAP +version+.
|
22
|
+
def initialize(endpoint, version = 1)
|
17
23
|
raise ArgumentError, "Invalid endpoint: #{endpoint}" unless /^http.+/ === endpoint
|
24
|
+
raise ArgumentError, "Invalid version: #{version}" unless SOAPVersions.include? version
|
18
25
|
@endpoint = URI(endpoint)
|
26
|
+
@version = version
|
19
27
|
end
|
20
28
|
|
21
29
|
# Returns an instance of Savon::WSDL.
|
@@ -50,8 +58,9 @@ module Savon
|
|
50
58
|
# Expects the requested +soap_action+ and +soap_body+ and builds and
|
51
59
|
# returns the request header and body to dispatch a SOAP request.
|
52
60
|
def build_request_parameters(soap_action, soap_body)
|
53
|
-
headers = { "Content-Type" =>
|
54
|
-
|
61
|
+
headers = { "Content-Type" => ContentType[@version], "SOAPAction" => soap_action }
|
62
|
+
namespaces = { :wsdl => wsdl.namespace_uri }
|
63
|
+
body = ApricotEatsGorilla.soap_envelope(namespaces, @version) do
|
55
64
|
ApricotEatsGorilla["wsdl:#{soap_action}" => soap_body]
|
56
65
|
end
|
57
66
|
[headers, body]
|
@@ -60,7 +69,13 @@ module Savon
|
|
60
69
|
# Expects a Hash containing information about a SOAP fault and raises
|
61
70
|
# a Savon::SOAPFault.
|
62
71
|
def raise_soap_fault(soap_fault)
|
63
|
-
|
72
|
+
message = case @version
|
73
|
+
when 1
|
74
|
+
"#{soap_fault[:faultcode]}: #{soap_fault[:faultstring]}"
|
75
|
+
else
|
76
|
+
"#{soap_fault[:code][:value]}: #{soap_fault[:reason][:text]}"
|
77
|
+
end
|
78
|
+
raise SOAPFault, message
|
64
79
|
end
|
65
80
|
|
66
81
|
# Expects a Net::HTTPResponse and raises a Savon::HTTPError.
|
data/spec/savon/service_spec.rb
CHANGED
@@ -6,8 +6,15 @@ describe Savon::Service do
|
|
6
6
|
# initialize
|
7
7
|
describe "initialize" do
|
8
8
|
it "raises an ArgumentError when called with an invalid endpoint" do
|
9
|
-
["", nil, "invalid", 123].each do |
|
10
|
-
lambda { Savon::Service.new(
|
9
|
+
["", nil, "invalid", 123].each do |argument|
|
10
|
+
lambda { Savon::Service.new(argument) }.should raise_error(ArgumentError)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
it "raises an ArgumentError when called with an invalid version" do
|
15
|
+
["", nil, "invalid", 123].each do |argument|
|
16
|
+
lambda { Savon::Service.new("http://example.com", argument) }.
|
17
|
+
should raise_error(ArgumentError)
|
11
18
|
end
|
12
19
|
end
|
13
20
|
end
|
@@ -42,7 +49,7 @@ describe Savon::Service do
|
|
42
49
|
@service.find_user(nil, "//email").should == "thedude@example.com"
|
43
50
|
end
|
44
51
|
|
45
|
-
it "returns nil if a given XPath does not match anything
|
52
|
+
it "returns nil if a given XPath does not match anything from the SOAP response" do
|
46
53
|
@service.find_user(nil, "//doesNotMatchAnything").should be_nil
|
47
54
|
end
|
48
55
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubiii-savon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Harrington
|
@@ -30,7 +30,7 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.5.
|
33
|
+
version: 0.5.6
|
34
34
|
version:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: rspec
|
@@ -52,8 +52,8 @@ dependencies:
|
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: 0.10.0
|
54
54
|
version:
|
55
|
-
description: SOAP client library to enjoy
|
56
|
-
email: me@
|
55
|
+
description: SOAP client library to enjoy
|
56
|
+
email: me@rubiii.com
|
57
57
|
executables: []
|
58
58
|
|
59
59
|
extensions: []
|
@@ -73,7 +73,7 @@ files:
|
|
73
73
|
- spec/savon/service_spec.rb
|
74
74
|
- spec/savon/wsdl_spec.rb
|
75
75
|
- spec/spec_helper.rb
|
76
|
-
has_rdoc:
|
76
|
+
has_rdoc: true
|
77
77
|
homepage: http://github.com/rubiii/savon
|
78
78
|
post_install_message:
|
79
79
|
rdoc_options:
|
@@ -103,9 +103,9 @@ requirements: []
|
|
103
103
|
rubyforge_project:
|
104
104
|
rubygems_version: 1.2.0
|
105
105
|
signing_key:
|
106
|
-
specification_version:
|
107
|
-
summary: SOAP client library to enjoy
|
106
|
+
specification_version: 2
|
107
|
+
summary: SOAP client library to enjoy
|
108
108
|
test_files:
|
109
|
-
- spec/spec_helper.rb
|
110
109
|
- spec/savon/service_spec.rb
|
111
110
|
- spec/savon/wsdl_spec.rb
|
111
|
+
- spec/spec_helper.rb
|