savon 0.7.4 → 0.7.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +6 -0
- data/README.rdoc +62 -0
- data/Rakefile +13 -9
- data/lib/savon.rb +16 -16
- data/lib/savon/client.rb +8 -21
- data/lib/savon/core_ext.rb +8 -2
- data/lib/savon/core_ext/array.rb +17 -0
- data/lib/savon/core_ext/datetime.rb +1 -1
- data/lib/savon/core_ext/hash.rb +51 -48
- data/lib/savon/core_ext/string.rb +15 -3
- data/lib/savon/core_ext/uri.rb +1 -1
- data/lib/savon/request.rb +2 -6
- data/lib/savon/response.rb +6 -3
- data/lib/savon/soap.rb +25 -8
- data/lib/savon/wsdl.rb +10 -3
- data/lib/savon/wsdl_stream.rb +5 -8
- data/lib/savon/wsse.rb +9 -13
- data/readme/client.rdoc +18 -0
- data/readme/errors.rdoc +11 -0
- data/readme/logging.rdoc +11 -0
- data/readme/participate.rdoc +21 -0
- data/readme/request.rdoc +37 -0
- data/readme/response.rdoc +46 -0
- data/readme/soap.rdoc +71 -0
- data/readme/value_mapping.rdoc +49 -0
- data/readme/wsdl.rdoc +39 -0
- data/readme/wsse.rdoc +28 -0
- data/spec/basic_spec_helper.rb +0 -1
- data/spec/savon/client_spec.rb +1 -1
- data/spec/savon/core_ext/array_spec.rb +19 -0
- data/spec/savon/core_ext/hash_spec.rb +94 -63
- data/spec/savon/core_ext/string_spec.rb +15 -0
- data/spec/savon/request_spec.rb +2 -2
- data/spec/savon/soap_spec.rb +40 -16
- metadata +17 -6
- data/README.textile +0 -71
- data/spec/savon/savon_spec.rb +0 -23
@@ -0,0 +1,49 @@
|
|
1
|
+
Of course both SOAP request and response are pure XML. Even though (assuming your XML applies to some defaults), Savon lets you specify the SOAP header and body as a Hash as well as returning the [[Response]] as a Hash.
|
2
|
+
|
3
|
+
== SOAP header and body
|
4
|
+
|
5
|
+
Some Hash keys and values passed to [[SOAP]] header and body are converted to SOAP compatible values automatically.
|
6
|
+
|
7
|
+
* Hash keys specified as Symbols are converted to lowerCamelCase Strings
|
8
|
+
* Hash keys specified as Strings are not converted and may contain namespaces
|
9
|
+
* DateTime Hash values are converted to xs:dateTime Strings
|
10
|
+
* Objects respond to to_datetime (except Strings) are converted to xs:dateTime Strings
|
11
|
+
* TrueClass and FalseClass objects are converted to "true" and "false"
|
12
|
+
* All other objects are expected to be converted to Strings using to_s
|
13
|
+
|
14
|
+
Example:
|
15
|
+
|
16
|
+
date = DateTime.new 2010, 11, 22, 11, 22, 33
|
17
|
+
response = client.user_magic do |soap|
|
18
|
+
soap.body = {
|
19
|
+
:magic_request => {
|
20
|
+
:perform_move => true,
|
21
|
+
"perform_at" => date
|
22
|
+
}
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
Request:
|
27
|
+
|
28
|
+
<env:Envelope
|
29
|
+
xmlns:wsdl="http://ws.user.example.com"
|
30
|
+
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
|
31
|
+
<env:Header></env:Header>
|
32
|
+
<env:Body>
|
33
|
+
<wsdl:userMagic>
|
34
|
+
<magicRequest>
|
35
|
+
<performMove>true</performMove>
|
36
|
+
<perform_at>2012-06-11T10:42:21</perform_at>
|
37
|
+
</magicRequest>
|
38
|
+
</wsdl:userMagic>
|
39
|
+
</env:Body>
|
40
|
+
</env:Envelope>
|
41
|
+
|
42
|
+
== SOAP response as a Hash
|
43
|
+
|
44
|
+
When translating the SOAP response to a Hash, some XML nodes and values are converted to more convenient Ruby objects. Translation is done using John Nunemaker's {Crack}[http://github.com/jnunemaker/crack] library. Afterward, Savon does some extra mapping.
|
45
|
+
|
46
|
+
* Hash keys get converted to snake_case Symbols and namespaces are stripped off
|
47
|
+
* SOAP nil values are converted to nil
|
48
|
+
* Hash values specified in xs:DateTime format are converted to DateTime objects
|
49
|
+
* Hash values of "true" and "false" are converted to TrueClass and FalseClass
|
data/readme/wsdl.rdoc
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
Savon::WSDL represents the WSDL of your service, including information like the namespace URI and available SOAP actions.
|
2
|
+
|
3
|
+
== Raw WSDL document
|
4
|
+
|
5
|
+
client.wsdl.to_s
|
6
|
+
|
7
|
+
== Available SOAP actions
|
8
|
+
|
9
|
+
client.wsdl.soap_actions
|
10
|
+
=> [:get_all_users, :get_user_by_id]
|
11
|
+
|
12
|
+
== Namespace URI
|
13
|
+
|
14
|
+
client.wsdl.namespace_uri
|
15
|
+
=> "http://ws.userservice.example.com"
|
16
|
+
|
17
|
+
== Disable Savon::WSDL
|
18
|
+
|
19
|
+
Especially with large services (i.e. Ebay), getting and parsing the WSDL document can really slow down your request. So in order to gain performance, you can disable the use of Savon::WSDL by simply appending an exclamation mark (!) to your SOAP call.
|
20
|
+
|
21
|
+
client.get_all_users!
|
22
|
+
|
23
|
+
Disabling Savon::WSDL comes with some disadvantages though. First of all, you need to know and specify the namespace URI of your service per request.
|
24
|
+
|
25
|
+
client.get_user_by_id! do |soap|
|
26
|
+
soap.namespace = "http://example.com/UserService"
|
27
|
+
soap.body = { :id => 666 }
|
28
|
+
end
|
29
|
+
|
30
|
+
Without a WSDL, Savon also has to guess the name of the SOAP action and input. It takes the name of the method called on its client instance, converts it to lowerCamelCase and uses the result. The SOAP call above expects a SOAP action with an original name of "getUserById".
|
31
|
+
|
32
|
+
If that doesn't fit the naming conventions of your service, you need to specify the names yourself. Here is an example request for a SOAP action called "GetUserById", requiring an input tag named "GetUserByIdRequest".
|
33
|
+
|
34
|
+
client.get_user_by_id! do |soap|
|
35
|
+
soap.action = "GetUserById"
|
36
|
+
soap.input = "GetUserByIdRequest"
|
37
|
+
soap.namespace = "http://example.com/UserService"
|
38
|
+
soap.body = { :id => 666 }
|
39
|
+
end
|
data/readme/wsse.rdoc
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
Savon::WSSE represents WSSE authentication. Pass a block to your SOAP call and the WSSE object is passed to it as the second argument. The object allows setting the WSSE username, password and whether to use digest authentication.
|
2
|
+
|
3
|
+
== Username and password
|
4
|
+
|
5
|
+
By default, Savon does not use WSSE authentication. Simply specify a username and password to change this.
|
6
|
+
|
7
|
+
response = client.get_all_users do |soap, wsse|
|
8
|
+
wsse.username = "gorilla"
|
9
|
+
wsse.password = "secret"
|
10
|
+
end
|
11
|
+
|
12
|
+
== Digest
|
13
|
+
|
14
|
+
To use WSSE digest authentication, just use the digest method to set digest authentication to true.
|
15
|
+
|
16
|
+
response = client.get_all_users do |soap, wsse|
|
17
|
+
wsse.username = "gorilla"
|
18
|
+
wsse.password = "secret"
|
19
|
+
wsse.digest = true
|
20
|
+
end
|
21
|
+
|
22
|
+
== Default to WSSE
|
23
|
+
|
24
|
+
In case all you're services require WSSE authentication, you can set your credentials and whether to use WSSE digest for every request:
|
25
|
+
|
26
|
+
Savon::WSSE.username = "dude"
|
27
|
+
Savon::WSSE.password = "secret"
|
28
|
+
Savon::WSSE.digest = true
|
data/spec/basic_spec_helper.rb
CHANGED
data/spec/savon/client_spec.rb
CHANGED
@@ -37,7 +37,7 @@ describe Savon::Client do
|
|
37
37
|
|
38
38
|
it "should disable the Savon::WSDL when passed a method with an exclamation mark" do
|
39
39
|
@client.wsdl.enabled?.should be_true
|
40
|
-
[:
|
40
|
+
[:operations, :namespace_uri, :soap_endpoint].each do |method|
|
41
41
|
Savon::WSDL.any_instance.expects(method).never
|
42
42
|
end
|
43
43
|
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Array do
|
4
|
+
|
5
|
+
describe "to_soap_xml" do
|
6
|
+
describe "should return SOAP request compatible XML" do
|
7
|
+
it "for an Array of Hashes" do
|
8
|
+
hash, result = [{ :name => "Eve" }], "<findUser><name>Eve</name></findUser>"
|
9
|
+
hash.to_soap_xml("findUser").should == result
|
10
|
+
end
|
11
|
+
|
12
|
+
it "for an Array of Strings and other Objects" do
|
13
|
+
hash, result = [:id, :name], "<someValues>id</someValues><someValues>name</someValues>"
|
14
|
+
hash.to_soap_xml("someValues").should == result
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -3,135 +3,166 @@ require "spec_helper"
|
|
3
3
|
describe Hash do
|
4
4
|
|
5
5
|
describe "find_soap_body" do
|
6
|
-
it "
|
7
|
-
{ "soap:Envelope" => { "soap:Body" => "content" } }
|
6
|
+
it "should return the content from the 'soap:Body' element" do
|
7
|
+
soap_body = { "soap:Envelope" => { "soap:Body" => "content" } }
|
8
|
+
soap_body.find_soap_body.should == "content"
|
8
9
|
end
|
9
10
|
|
10
|
-
it "
|
11
|
-
{ "some_hash" => "content" }
|
11
|
+
it "should return an empty Hash in case the 'soap:Body' element could not be found" do
|
12
|
+
soap_body = { "some_hash" => "content" }
|
13
|
+
soap_body.find_soap_body.should == {}
|
12
14
|
end
|
13
15
|
end
|
14
16
|
|
15
17
|
describe "to_soap_xml" do
|
16
|
-
describe "
|
18
|
+
describe "should return SOAP request compatible XML" do
|
17
19
|
it "for a simple Hash" do
|
18
|
-
{ :some => "user" }
|
20
|
+
hash, result = { :some => "user" }, "<some>user</some>"
|
21
|
+
hash.to_soap_xml.should == result
|
19
22
|
end
|
20
23
|
|
21
24
|
it "for a nested Hash" do
|
22
|
-
{ :some => { :new => "user" } }
|
23
|
-
|
25
|
+
hash, result = { :some => { :new => "user" } }, "<some><new>user</new></some>"
|
26
|
+
hash.to_soap_xml.should == result
|
24
27
|
end
|
25
28
|
|
26
29
|
it "for a Hash with multiple keys" do
|
27
|
-
|
28
|
-
|
29
|
-
soap_xml.should include("<all>users</all>")
|
30
|
-
soap_xml.should include("<before>whatever</before>")
|
30
|
+
hash = { :all => "users", :before => "whatever" }
|
31
|
+
hash.to_soap_xml.should include("<all>users</all>", "<before>whatever</before>")
|
31
32
|
end
|
32
33
|
|
33
34
|
it "for a Hash containing an Array" do
|
34
|
-
{ :some => ["user", "gorilla"] }
|
35
|
-
|
35
|
+
hash, result = { :some => ["user", "gorilla"] }, "<some>user</some><some>gorilla</some>"
|
36
|
+
hash.to_soap_xml.should == result
|
36
37
|
end
|
37
38
|
|
38
39
|
it "for a Hash containing an Array of Hashes" do
|
39
|
-
{ :some => [{ :new => "user" }, { :old => "gorilla" }] }
|
40
|
-
|
40
|
+
hash = { :some => [{ :new => "user" }, { :old => "gorilla" }] }
|
41
|
+
result = "<some><new>user</new></some><some><old>gorilla</old></some>"
|
42
|
+
|
43
|
+
hash.to_soap_xml.should == result
|
41
44
|
end
|
42
45
|
end
|
43
46
|
|
44
|
-
it "
|
45
|
-
{ :find_or_create => "user" }
|
46
|
-
|
47
|
+
it "should convert Hash key Symbols to lowerCamelCase" do
|
48
|
+
hash, result = { :find_or_create => "user" }, "<findOrCreate>user</findOrCreate>"
|
49
|
+
hash.to_soap_xml.should == result
|
47
50
|
end
|
48
51
|
|
49
|
-
it "
|
50
|
-
{ "find_or_create" => "user" }
|
51
|
-
|
52
|
+
it "should not convert Hash key Strings" do
|
53
|
+
hash, result = { "find_or_create" => "user" }, "<find_or_create>user</find_or_create>"
|
54
|
+
hash.to_soap_xml.should == result
|
52
55
|
end
|
53
56
|
|
54
|
-
it "
|
55
|
-
{ :before => DateTime.new(2012, 03, 22, 16, 22, 33) }
|
56
|
-
|
57
|
+
it "should convert DateTime objects to xs:dateTime compliant Strings" do
|
58
|
+
hash = { :before => DateTime.new(2012, 03, 22, 16, 22, 33) }
|
59
|
+
result = "<before>2012-03-22T16:22:33Z</before>"
|
60
|
+
|
61
|
+
hash.to_soap_xml.should == result
|
57
62
|
end
|
58
63
|
|
59
|
-
it "
|
64
|
+
it "should convert Objects responding to to_datetime to xs:dateTime compliant Strings" do
|
60
65
|
singleton = Object.new
|
61
66
|
def singleton.to_datetime
|
62
67
|
DateTime.new(2012, 03, 22, 16, 22, 33)
|
63
68
|
end
|
64
69
|
|
65
|
-
{ :before => singleton }
|
66
|
-
|
70
|
+
hash, result = { :before => singleton }, "<before>2012-03-22T16:22:33Z</before>"
|
71
|
+
hash.to_soap_xml.should == result
|
67
72
|
end
|
68
73
|
|
69
|
-
it "
|
74
|
+
it "should call to_s on Strings even if they respond to to_datetime" do
|
70
75
|
object = "gorilla"
|
71
76
|
object.expects(:to_s).returns object
|
72
77
|
object.expects(:to_datetime).never
|
73
78
|
|
74
|
-
{ :name => object }
|
79
|
+
hash, result = { :name => object }, "<name>gorilla</name>"
|
80
|
+
hash.to_soap_xml.should == result
|
75
81
|
end
|
76
82
|
|
77
|
-
it "call to_s on any other Object" do
|
83
|
+
it "should call to_s on any other Object" do
|
78
84
|
[666, true, false, nil].each do |object|
|
79
85
|
{ :some => object }.to_soap_xml.should == "<some>#{object}</some>"
|
80
86
|
end
|
81
87
|
end
|
82
88
|
|
83
|
-
it "
|
84
|
-
{ :find_user => { :name => "Lucy", :id => 666,
|
85
|
-
|
89
|
+
it "should preserve the order of Hash keys and values specified through :order!" do
|
90
|
+
hash = { :find_user => { :name => "Lucy", :id => 666, :order! => [:id, :name] } }
|
91
|
+
result = "<findUser><id>666</id><name>Lucy</name></findUser>"
|
92
|
+
hash.to_soap_xml.should == result
|
86
93
|
|
87
|
-
|
88
|
-
|
89
|
-
|
94
|
+
hash = { :find_user => { :mname => "in the", :lname => "Sky", :fname => "Lucy", :order! => [:fname, :mname, :lname] } }
|
95
|
+
result = "<findUser><fname>Lucy</fname><mname>in the</mname><lname>Sky</lname></findUser>"
|
96
|
+
hash.to_soap_xml.should == result
|
90
97
|
end
|
91
98
|
|
92
|
-
it "
|
93
|
-
|
94
|
-
|
99
|
+
it "should raise an error if the :order! Array does not match the Hash keys" do
|
100
|
+
hash = { :name => "Lucy", :id => 666, :order! => [:name] }
|
101
|
+
lambda { hash.to_soap_xml }.should raise_error(ArgumentError)
|
95
102
|
|
96
|
-
|
97
|
-
|
103
|
+
hash = { :by_name => { :name => "Lucy", :lname => "Sky", :order! => [:mname, :name] } }
|
104
|
+
lambda { hash.to_soap_xml }.should raise_error(ArgumentError)
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should add attributes to Hash keys specified through :attributes!" do
|
108
|
+
hash = { :find_user => { :person => "Lucy", :attributes! => { :person => { :id => 666 } } } }
|
109
|
+
result = '<findUser><person id="666">Lucy</person></findUser>'
|
110
|
+
hash.to_soap_xml.should == result
|
111
|
+
|
112
|
+
hash = { :find_user => { :person => "Lucy", :attributes! => { :person => { :id => 666, :city => "Hamburg" } } } }
|
113
|
+
soap_xml = hash.to_soap_xml
|
114
|
+
soap_xml.should include('id="666"', 'city="Hamburg"')
|
98
115
|
end
|
99
116
|
end
|
100
117
|
|
101
118
|
describe "map_soap_response" do
|
102
|
-
it "
|
103
|
-
{ "userResponse" => { "accountStatus" => "active" } }
|
104
|
-
|
119
|
+
it "should convert Hash key Strings to snake_case Symbols" do
|
120
|
+
soap_response = { "userResponse" => { "accountStatus" => "active" } }
|
121
|
+
result = { :user_response => { :account_status => "active" } }
|
122
|
+
|
123
|
+
soap_response.map_soap_response.should == result
|
105
124
|
end
|
106
125
|
|
107
|
-
it "
|
108
|
-
{ "ns:userResponse" => { "ns2:id" => "666" } }
|
109
|
-
|
126
|
+
it "should strip namespaces from Hash keys" do
|
127
|
+
soap_response = { "ns:userResponse" => { "ns2:id" => "666" } }
|
128
|
+
result = { :user_response => { :id => "666" } }
|
129
|
+
|
130
|
+
soap_response.map_soap_response.should == result
|
110
131
|
end
|
111
132
|
|
112
|
-
it "
|
113
|
-
{ "response" => [{ "name" => "dude" }, { "name" => "gorilla" }] }
|
114
|
-
|
133
|
+
it "should convert Hash keys and values in Arrays" do
|
134
|
+
soap_response = { "response" => [{ "name" => "dude" }, { "name" => "gorilla" }] }
|
135
|
+
result = { :response=> [{ :name => "dude" }, { :name => "gorilla" }] }
|
136
|
+
|
137
|
+
soap_response.map_soap_response.should == result
|
115
138
|
end
|
116
139
|
|
117
|
-
it "
|
118
|
-
{ "userResponse" => { "xsi:nil" => "true" } }
|
119
|
-
|
140
|
+
it "should convert xsi:nil values to nil Objects" do
|
141
|
+
soap_response = { "userResponse" => { "xsi:nil" => "true" } }
|
142
|
+
result = { :user_response => nil }
|
143
|
+
|
144
|
+
soap_response.map_soap_response.should == result
|
120
145
|
end
|
121
146
|
|
122
|
-
it "
|
123
|
-
{ "response" => { "at" => "2012-03-22T16:22:33" } }
|
124
|
-
|
147
|
+
it "should convert Hash values matching the xs:dateTime format into DateTime Objects" do
|
148
|
+
soap_response = { "response" => { "at" => "2012-03-22T16:22:33" } }
|
149
|
+
result = { :response => { :at => DateTime.new(2012, 03, 22, 16, 22, 33) } }
|
150
|
+
|
151
|
+
soap_response.map_soap_response.should == result
|
125
152
|
end
|
126
153
|
|
127
|
-
it "
|
128
|
-
{ "response" => { "active" => "false" } }
|
129
|
-
|
154
|
+
it "should convert Hash values matching 'true' to TrueClass" do
|
155
|
+
soap_response = { "response" => { "active" => "false" } }
|
156
|
+
result = { :response => { :active => false } }
|
157
|
+
|
158
|
+
soap_response.map_soap_response.should == result
|
130
159
|
end
|
131
160
|
|
132
|
-
it "
|
133
|
-
{ "response" => { "active" => "true" } }
|
134
|
-
|
161
|
+
it "should convert Hash values matching 'false' to FalseClass" do
|
162
|
+
soap_response = { "response" => { "active" => "true" } }
|
163
|
+
result = { :response => { :active => true } }
|
164
|
+
|
165
|
+
soap_response.map_soap_response.should == result
|
135
166
|
end
|
136
167
|
end
|
137
168
|
|
@@ -30,6 +30,21 @@ describe String do
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
+
describe "starts_with?" do
|
34
|
+
it "should return whether it starts with a given suffix" do
|
35
|
+
"authenticate".starts_with?("auth").should be_true
|
36
|
+
"authenticate".starts_with?("cate").should be_false
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "ends_with?" do
|
41
|
+
it "should return whether it ends with a given suffix" do
|
42
|
+
"authenticate!".ends_with?("!").should be_true
|
43
|
+
"authenticate".ends_with?("cate").should be_true
|
44
|
+
"authenticate".ends_with?("?").should be_false
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
33
48
|
describe "strip_namespace" do
|
34
49
|
it "strips the namespace from a namespaced String" do
|
35
50
|
"ns:customer".strip_namespace.should == "customer"
|
data/spec/savon/request_spec.rb
CHANGED
@@ -76,8 +76,8 @@ describe Savon::Request do
|
|
76
76
|
end
|
77
77
|
|
78
78
|
it "executes a SOAP request and returns the Net::HTTP response" do
|
79
|
-
|
80
|
-
soap
|
79
|
+
some_operation = WSDLFixture.authentication(:operations)[:authenticate]
|
80
|
+
soap = Savon::SOAP.new some_operation, EndpointHelper.soap_endpoint
|
81
81
|
soap_response = @request.soap soap
|
82
82
|
|
83
83
|
soap_response.should be_a(Net::HTTPResponse)
|
data/spec/savon/soap_spec.rb
CHANGED
@@ -2,24 +2,42 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe Savon::SOAP do
|
4
4
|
before do
|
5
|
-
@
|
6
|
-
@soap
|
5
|
+
@authenticate_operation = WSDLFixture.authentication(:operations)[:authenticate]
|
6
|
+
@soap = Savon::SOAP.new @authenticate_operation, EndpointHelper.soap_endpoint
|
7
7
|
end
|
8
8
|
|
9
9
|
it "contains the SOAP namespace for each supported SOAP version" do
|
10
|
-
Savon::
|
11
|
-
Savon::SOAP::
|
12
|
-
Savon::SOAP::
|
10
|
+
Savon::SOAP::Versions.each do |soap_version|
|
11
|
+
Savon::SOAP::Namespace[soap_version].should be_a(String)
|
12
|
+
Savon::SOAP::Namespace[soap_version].should_not be_empty
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
16
|
it "contains the Content-Types for each supported SOAP version" do
|
17
|
-
Savon::
|
17
|
+
Savon::SOAP::Versions.each do |soap_version|
|
18
18
|
Savon::SOAP::ContentType[soap_version].should be_a(String)
|
19
19
|
Savon::SOAP::ContentType[soap_version].should_not be_empty
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
+
it "contains an Array of supported SOAP versions" do
|
24
|
+
Savon::SOAP::Versions.should be_an(Array)
|
25
|
+
Savon::SOAP::Versions.should_not be_empty
|
26
|
+
end
|
27
|
+
|
28
|
+
it "contains the xs:dateTime format" do
|
29
|
+
Savon::SOAP::DateTimeFormat.should be_a(String)
|
30
|
+
Savon::SOAP::DateTimeFormat.should_not be_empty
|
31
|
+
|
32
|
+
DateTime.new(2012, 03, 22, 16, 22, 33).strftime(Savon::SOAP::DateTimeFormat).
|
33
|
+
should == "2012-03-22T16:22:33Z"
|
34
|
+
end
|
35
|
+
|
36
|
+
it "contains a Regexp matching the xs:dateTime format" do
|
37
|
+
Savon::SOAP::DateTimeRegexp.should be_a(Regexp)
|
38
|
+
(Savon::SOAP::DateTimeRegexp === "2012-03-22T16:22:33").should be_true
|
39
|
+
end
|
40
|
+
|
23
41
|
it "defaults to SOAP 1.1" do
|
24
42
|
Savon::SOAP.version.should == 1
|
25
43
|
end
|
@@ -35,15 +53,22 @@ describe Savon::SOAP do
|
|
35
53
|
@soap.wsse = Savon::WSSE.new
|
36
54
|
end
|
37
55
|
|
38
|
-
it "
|
39
|
-
@soap.action.should ==
|
56
|
+
it "has both getter and setter for the SOAP action" do
|
57
|
+
@soap.action.should == @authenticate_operation[:action]
|
40
58
|
|
41
59
|
@soap.action = "someAction"
|
42
60
|
@soap.action.should == "someAction"
|
43
61
|
end
|
44
62
|
|
45
|
-
it "has
|
46
|
-
@soap.input
|
63
|
+
it "has both getter and setter for the SOAP input" do
|
64
|
+
@soap.input.should == @authenticate_operation[:input]
|
65
|
+
|
66
|
+
@soap.input = "whatever"
|
67
|
+
@soap.input.should == "whatever"
|
68
|
+
|
69
|
+
args = "FindUserRequest", { "username" => "auser", "anotherAttr" => "someVal" }
|
70
|
+
@soap.input = *args
|
71
|
+
@soap.input.should == [*args]
|
47
72
|
end
|
48
73
|
|
49
74
|
it "has both getter and setter for global SOAP headers" do
|
@@ -75,12 +100,12 @@ describe Savon::SOAP do
|
|
75
100
|
|
76
101
|
describe "has a getter for namespaces" do
|
77
102
|
it "which defaults to include the SOAP 1.1 namespace" do
|
78
|
-
@soap.namespaces.should == { "xmlns:env" => Savon::SOAP::
|
103
|
+
@soap.namespaces.should == { "xmlns:env" => Savon::SOAP::Namespace[1] }
|
79
104
|
end
|
80
105
|
|
81
106
|
it "which contains the SOAP 1.2 namespace if specified" do
|
82
107
|
@soap.version = 2
|
83
|
-
@soap.namespaces.should == { "xmlns:env" => Savon::SOAP::
|
108
|
+
@soap.namespaces.should == { "xmlns:env" => Savon::SOAP::Namespace[2] }
|
84
109
|
end
|
85
110
|
end
|
86
111
|
|
@@ -101,9 +126,8 @@ describe Savon::SOAP do
|
|
101
126
|
end
|
102
127
|
|
103
128
|
it "has both getter and setter for the SOAP endpoint" do
|
104
|
-
@soap.endpoint.should be_nil
|
105
|
-
|
106
129
|
soap_endpoint = URI EndpointHelper.soap_endpoint
|
130
|
+
|
107
131
|
@soap.endpoint = soap_endpoint
|
108
132
|
@soap.endpoint.should == soap_endpoint
|
109
133
|
end
|
@@ -147,12 +171,12 @@ describe Savon::SOAP do
|
|
147
171
|
|
148
172
|
it "uses the SOAP namespace for the specified SOAP version" do
|
149
173
|
@soap.version = 2
|
150
|
-
@soap.to_xml.should include(Savon::SOAP::
|
174
|
+
@soap.to_xml.should include(Savon::SOAP::Namespace[2])
|
151
175
|
end
|
152
176
|
|
153
177
|
it "uses the SOAP namespace for the default SOAP version otherwise" do
|
154
178
|
Savon::SOAP.version = 2
|
155
|
-
@soap.to_xml.should include(Savon::SOAP::
|
179
|
+
@soap.to_xml.should include(Savon::SOAP::Namespace[2])
|
156
180
|
end
|
157
181
|
|
158
182
|
it "merges global and per request headers defined as Hashes" do
|