savon 0.6.0 → 0.6.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/README.textile +21 -12
- data/VERSION +1 -1
- data/lib/savon/wsse.rb +6 -2
- data/spec/savon/wsse_spec.rb +14 -24
- metadata +1 -1
data/README.textile
CHANGED
|
@@ -15,15 +15,15 @@ p. To use this heavy metal library, you should be familiar with SOAP, WSDL and t
|
|
|
15
15
|
|
|
16
16
|
h2. Instantiate Savon::Client
|
|
17
17
|
|
|
18
|
-
p. Instantiate
|
|
18
|
+
p. Instantiate Savon::Client, passing in the WSDL of your service.
|
|
19
19
|
|
|
20
|
-
bc.
|
|
20
|
+
bc. client = Savon::Client.new "http://example.com/UserService?wsdl"
|
|
21
21
|
|
|
22
22
|
h2. The WSDL
|
|
23
23
|
|
|
24
24
|
p. You can find out about the SOAP actions available on the webservice by using the WSDL object.
|
|
25
25
|
|
|
26
|
-
bc.
|
|
26
|
+
bc. client.wsdl.soap_actions.keys
|
|
27
27
|
=> [:get_all_users, :get_user_by_id, :user_magic]
|
|
28
28
|
|
|
29
29
|
p. Find out more about the "WSDL":http://wiki.github.com/rubiii/savon/wsdl object.
|
|
@@ -32,24 +32,33 @@ h2. Calling a SOAP action
|
|
|
32
32
|
|
|
33
33
|
p. Now, assuming your service applies to the default "Options":http://wiki.github.com/rubiii/savon/options, you can just call any available SOAP action.
|
|
34
34
|
|
|
35
|
-
bc. response =
|
|
35
|
+
bc. response = client.get_all_users
|
|
36
36
|
|
|
37
37
|
p. Savon lets you call SOAP actions using snake_case, because even though they will propably be written in lowerCamelCase or CamelCase, it just feels much more natural.
|
|
38
38
|
|
|
39
|
-
h2.
|
|
39
|
+
h2. The SOAP object
|
|
40
40
|
|
|
41
|
-
p.
|
|
41
|
+
p. Pass a block to the SOAP request which expects a single variable and Savon will hand you the SOAP object to specify various SOAP-related options.
|
|
42
42
|
|
|
43
|
-
bc. response =
|
|
43
|
+
bc. response = client.get_user_by_id { |soap| soap.body = { :id => 666 } }
|
|
44
44
|
|
|
45
|
-
p. Learn more about
|
|
45
|
+
p. Learn more about the "SOAP":http://wiki.github.com/rubiii/savon/soap object.
|
|
46
46
|
|
|
47
|
-
h2. The
|
|
47
|
+
h2. The WSSE object
|
|
48
|
+
|
|
49
|
+
p. Pass a block to the SOAP request which expects two variables and Savon will yield the SOAP and WSSE objects.
|
|
50
|
+
|
|
51
|
+
bc. response = client.get_user_by_id do |soap, wsse|
|
|
52
|
+
wsse.username = "gorilla"
|
|
53
|
+
wsse.password = "secret"
|
|
54
|
+
soap.body = { :id => 666 }
|
|
55
|
+
end
|
|
48
56
|
|
|
49
|
-
p.
|
|
57
|
+
p. Learn more about the "WSSE":http://wiki.github.com/rubiii/savon/wsse object.
|
|
58
|
+
|
|
59
|
+
h2. The response
|
|
50
60
|
|
|
51
|
-
|
|
52
|
-
=> { :user_response => { :id => "666", :username => "gorilla" } }
|
|
61
|
+
p. The response is wrapped in an object to give you various options of handling it. Take a look at the "Response":http://wiki.github.com/rubiii/savon/response for more information.
|
|
53
62
|
|
|
54
63
|
h2. HTTP errors and SOAP faults
|
|
55
64
|
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.6.
|
|
1
|
+
0.6.1
|
data/lib/savon/wsse.rb
CHANGED
|
@@ -12,10 +12,10 @@ module Savon
|
|
|
12
12
|
WSUNamespace = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
|
|
13
13
|
|
|
14
14
|
# Default WSSE username.
|
|
15
|
-
@username =
|
|
15
|
+
@username = nil
|
|
16
16
|
|
|
17
17
|
# Default WSSE password.
|
|
18
|
-
@password =
|
|
18
|
+
@password = nil
|
|
19
19
|
|
|
20
20
|
# Default for whether to use WSSE digest.
|
|
21
21
|
@digest = false
|
|
@@ -28,6 +28,7 @@ module Savon
|
|
|
28
28
|
# Sets the default WSSE username.
|
|
29
29
|
def username=(username)
|
|
30
30
|
@username = username.to_s if username.respond_to? :to_s
|
|
31
|
+
@username = nil if username.nil?
|
|
31
32
|
end
|
|
32
33
|
|
|
33
34
|
# Returns the default WSSE password.
|
|
@@ -36,6 +37,7 @@ module Savon
|
|
|
36
37
|
# Sets the default WSSE password.
|
|
37
38
|
def password=(password)
|
|
38
39
|
@password = password.to_s if password.respond_to? :to_s
|
|
40
|
+
@password = nil if password.nil?
|
|
39
41
|
end
|
|
40
42
|
|
|
41
43
|
# Sets whether to use WSSE digest by default.
|
|
@@ -51,6 +53,7 @@ module Savon
|
|
|
51
53
|
# Sets the WSSE username.
|
|
52
54
|
def username=(username)
|
|
53
55
|
@username = username.to_s if username.respond_to? :to_s
|
|
56
|
+
@username = nil if username.nil?
|
|
54
57
|
end
|
|
55
58
|
|
|
56
59
|
# Returns the WSSE username. Defaults to the global default.
|
|
@@ -61,6 +64,7 @@ module Savon
|
|
|
61
64
|
# Sets the WSSE password.
|
|
62
65
|
def password=(password)
|
|
63
66
|
@password = password.to_s if password.respond_to? :to_s
|
|
67
|
+
@password = nil if password.nil?
|
|
64
68
|
end
|
|
65
69
|
|
|
66
70
|
# Returns the WSSE password. Defaults to the global default.
|
data/spec/savon/wsse_spec.rb
CHANGED
|
@@ -2,9 +2,12 @@ require "spec_helper"
|
|
|
2
2
|
|
|
3
3
|
describe Savon::WSSE do
|
|
4
4
|
before do
|
|
5
|
+
Savon::WSSE.username = nil
|
|
6
|
+
Savon::WSSE.password = nil
|
|
7
|
+
Savon::WSSE.digest = false
|
|
8
|
+
|
|
5
9
|
@wsse = Savon::WSSE.new
|
|
6
|
-
@username = "gorilla"
|
|
7
|
-
@password = "secret"
|
|
10
|
+
@username, @password = "gorilla", "secret"
|
|
8
11
|
end
|
|
9
12
|
|
|
10
13
|
describe "WSENamespace" do
|
|
@@ -22,28 +25,24 @@ describe Savon::WSSE do
|
|
|
22
25
|
end
|
|
23
26
|
|
|
24
27
|
describe "@username" do
|
|
25
|
-
it "defaults to
|
|
26
|
-
Savon::WSSE.username.should
|
|
27
|
-
Savon::WSSE.username.should be_empty
|
|
28
|
+
it "defaults to nil" do
|
|
29
|
+
Savon::WSSE.username.should be_nil
|
|
28
30
|
end
|
|
29
31
|
|
|
30
32
|
it "has accessor methods" do
|
|
31
33
|
Savon::WSSE.username = "gorilla"
|
|
32
34
|
Savon::WSSE.username.should == "gorilla"
|
|
33
|
-
Savon::WSSE.username = ""
|
|
34
35
|
end
|
|
35
36
|
end
|
|
36
37
|
|
|
37
38
|
describe "@password" do
|
|
38
|
-
it "defaults to
|
|
39
|
-
Savon::WSSE.password.should
|
|
40
|
-
Savon::WSSE.password.should be_empty
|
|
39
|
+
it "defaults to nil" do
|
|
40
|
+
Savon::WSSE.password.should be_nil
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
it "has accessor methods" do
|
|
44
44
|
Savon::WSSE.password = "secret"
|
|
45
45
|
Savon::WSSE.password.should == "secret"
|
|
46
|
-
Savon::WSSE.password = ""
|
|
47
46
|
end
|
|
48
47
|
end
|
|
49
48
|
|
|
@@ -55,33 +54,28 @@ describe Savon::WSSE do
|
|
|
55
54
|
it "has accessor methods" do
|
|
56
55
|
Savon::WSSE.digest = true
|
|
57
56
|
Savon::WSSE.digest?.should == true
|
|
58
|
-
Savon::WSSE.digest = false
|
|
59
57
|
end
|
|
60
58
|
end
|
|
61
59
|
|
|
62
60
|
describe "username" do
|
|
63
|
-
it "defaults to
|
|
64
|
-
@wsse.username.should
|
|
65
|
-
@wsse.username.should be_empty
|
|
61
|
+
it "defaults to nil" do
|
|
62
|
+
@wsse.username.should be_nil
|
|
66
63
|
end
|
|
67
64
|
|
|
68
65
|
it "has accessor methods" do
|
|
69
66
|
@wsse.username = "gorilla"
|
|
70
67
|
@wsse.username.should == "gorilla"
|
|
71
|
-
@wsse.username = nil
|
|
72
68
|
end
|
|
73
69
|
end
|
|
74
70
|
|
|
75
71
|
describe "password" do
|
|
76
|
-
it "defaults to
|
|
77
|
-
@wsse.password.should
|
|
78
|
-
@wsse.password.should be_empty
|
|
72
|
+
it "defaults to nil" do
|
|
73
|
+
@wsse.password.should be_nil
|
|
79
74
|
end
|
|
80
75
|
|
|
81
76
|
it "has accessor methods" do
|
|
82
77
|
@wsse.password = "secret"
|
|
83
78
|
@wsse.password.should == "secret"
|
|
84
|
-
@wsse.password = nil
|
|
85
79
|
end
|
|
86
80
|
end
|
|
87
81
|
|
|
@@ -93,7 +87,6 @@ describe Savon::WSSE do
|
|
|
93
87
|
it "has accessor methods" do
|
|
94
88
|
@wsse.digest = true
|
|
95
89
|
@wsse.digest?.should == true
|
|
96
|
-
@wsse.digest = false
|
|
97
90
|
end
|
|
98
91
|
end
|
|
99
92
|
|
|
@@ -117,9 +110,6 @@ describe Savon::WSSE do
|
|
|
117
110
|
header.should include_security_namespaces
|
|
118
111
|
header.should include @username
|
|
119
112
|
header.should include @password
|
|
120
|
-
|
|
121
|
-
Savon::WSSE.username = ""
|
|
122
|
-
Savon::WSSE.password = ""
|
|
123
113
|
end
|
|
124
114
|
end
|
|
125
115
|
|
|
@@ -155,4 +145,4 @@ describe Savon::WSSE do
|
|
|
155
145
|
end
|
|
156
146
|
end
|
|
157
147
|
|
|
158
|
-
end
|
|
148
|
+
end
|