savon 0.6.0 → 0.7.0
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 +112 -0
- data/README.textile +42 -35
- data/Rakefile +28 -33
- data/lib/savon/client.rb +42 -19
- data/lib/savon/core_ext/hash.rb +35 -22
- data/lib/savon/core_ext/net_http.rb +20 -0
- data/lib/savon/core_ext/object.rb +7 -0
- data/lib/savon/core_ext/string.rb +1 -1
- data/lib/savon/core_ext.rb +2 -2
- data/lib/savon/request.rb +73 -33
- data/lib/savon/response.rb +23 -36
- data/lib/savon/soap.rb +63 -30
- data/lib/savon/wsdl.rb +82 -35
- data/lib/savon/wsse.rb +41 -35
- data/lib/savon.rb +3 -2
- data/spec/basic_spec_helper.rb +12 -0
- data/spec/endpoint_helper.rb +22 -0
- data/spec/fixtures/response/response_fixture.rb +36 -0
- data/spec/fixtures/response/xml/authentication.xml +14 -0
- data/spec/fixtures/response/xml/multi_ref.xml +39 -0
- data/spec/fixtures/response/xml/soap_fault12.xml +18 -0
- data/spec/fixtures/wsdl/wsdl_fixture.rb +37 -0
- data/spec/fixtures/wsdl/xml/authentication.xml +63 -0
- data/spec/fixtures/wsdl/xml/namespaced_actions.xml +307 -0
- data/spec/fixtures/wsdl/xml/no_namespace.xml +115 -0
- data/spec/http_stubs.rb +17 -19
- data/spec/integration/http_basic_auth_spec.rb +12 -0
- data/spec/integration/server.rb +51 -0
- data/spec/savon/client_spec.rb +52 -44
- data/spec/savon/core_ext/datetime_spec.rb +2 -2
- data/spec/savon/core_ext/hash_spec.rb +34 -31
- data/spec/savon/core_ext/net_http_spec.rb +38 -0
- data/spec/savon/core_ext/object_spec.rb +16 -2
- data/spec/savon/core_ext/string_spec.rb +4 -4
- data/spec/savon/core_ext/symbol_spec.rb +1 -1
- data/spec/savon/core_ext/uri_spec.rb +1 -1
- data/spec/savon/request_spec.rb +49 -63
- data/spec/savon/response_spec.rb +48 -51
- data/spec/savon/savon_spec.rb +12 -19
- data/spec/savon/soap_spec.rb +81 -90
- data/spec/savon/wsdl_spec.rb +62 -30
- data/spec/savon/wsse_spec.rb +58 -84
- data/spec/spec_helper.rb +3 -13
- metadata +29 -15
- data/VERSION +0 -1
- data/spec/fixtures/multiple_user_response.xml +0 -22
- data/spec/fixtures/user_fixture.rb +0 -54
- data/spec/fixtures/user_response.xml +0 -15
- data/spec/fixtures/user_wsdl.xml +0 -124
- data/spec/spec_helper_methods.rb +0 -33
- /data/spec/fixtures/{soap_fault.xml → response/xml/soap_fault.xml} +0 -0
data/spec/savon/request_spec.rb
CHANGED
|
@@ -1,92 +1,78 @@
|
|
|
1
1
|
require "spec_helper"
|
|
2
2
|
|
|
3
3
|
describe Savon::Request do
|
|
4
|
-
before { @request =
|
|
4
|
+
before { @request = Savon::Request.new EndpointHelper.wsdl_endpoint }
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
Savon::
|
|
6
|
+
it "contains the ContentType for each supported SOAP version" do
|
|
7
|
+
Savon::SOAPVersions.each do |soap_version|
|
|
8
|
+
Savon::Request::ContentType[soap_version].should be_a(String)
|
|
9
|
+
Savon::Request::ContentType[soap_version].should_not be_empty
|
|
10
|
+
end
|
|
8
11
|
end
|
|
9
12
|
|
|
10
|
-
|
|
11
|
-
Savon::SOAP.new UserFixture.soap_actions[:find_user]
|
|
12
|
-
end
|
|
13
|
+
# defaults to log request and response. disabled for spec execution
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
end
|
|
20
|
-
end
|
|
15
|
+
it "has both getter and setter for whether to log (global setting)" do
|
|
16
|
+
Savon::Request.log = true
|
|
17
|
+
Savon::Request.log?.should be_true
|
|
18
|
+
Savon::Request.log = false
|
|
19
|
+
Savon::Request.log?.should be_false
|
|
21
20
|
end
|
|
22
21
|
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
it "defaults to use a Logger instance for logging" do
|
|
23
|
+
Savon::Request.logger.should be_a(Logger)
|
|
24
|
+
end
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
Savon::Request.log?.should be_false
|
|
31
|
-
end
|
|
26
|
+
it "has both getter and setter for the logger to use (global setting)" do
|
|
27
|
+
Savon::Request.logger = nil
|
|
28
|
+
Savon::Request.logger.should be_nil
|
|
29
|
+
Savon::Request.logger = Logger.new STDOUT
|
|
32
30
|
end
|
|
33
31
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
end
|
|
32
|
+
it "defaults to :debug for logging" do
|
|
33
|
+
Savon::Request.log_level.should == :debug
|
|
34
|
+
end
|
|
38
35
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
end
|
|
36
|
+
it "has both getter and setter for the log level to use (global setting)" do
|
|
37
|
+
Savon::Request.log_level = :info
|
|
38
|
+
Savon::Request.log_level.should == :info
|
|
39
|
+
Savon::Request.log_level = :debug
|
|
44
40
|
end
|
|
45
41
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
end
|
|
42
|
+
it "is initialized with a SOAP endpoint String" do
|
|
43
|
+
Savon::Request.new EndpointHelper.wsdl_endpoint
|
|
44
|
+
end
|
|
50
45
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
Savon::Request.log_level.should == :info
|
|
54
|
-
Savon::Request.log_level = :debug
|
|
55
|
-
end
|
|
46
|
+
it "has a getter for the SOAP endpoint URI" do
|
|
47
|
+
@request.endpoint.should == URI(EndpointHelper.wsdl_endpoint)
|
|
56
48
|
end
|
|
57
49
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
end
|
|
50
|
+
it "should have a getter for the proxy URI" do
|
|
51
|
+
@request.proxy.should == URI("")
|
|
52
|
+
end
|
|
62
53
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
end
|
|
54
|
+
it "should return the Net::HTTP object" do
|
|
55
|
+
@request.http.should be_kind_of(Net::HTTP)
|
|
66
56
|
end
|
|
67
57
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
@request.endpoint.should == SpecHelper.some_endpoint_uri
|
|
71
|
-
end
|
|
58
|
+
it "should have a method for setting HTTP basic auth credentials" do
|
|
59
|
+
@request.basic_auth "user", "password"
|
|
72
60
|
end
|
|
73
61
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
wsdl_response = @request.wsdl
|
|
62
|
+
it "retrieves the WSDL document and returns the Net::HTTP response" do
|
|
63
|
+
wsdl_response = @request.wsdl
|
|
77
64
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
end
|
|
65
|
+
wsdl_response.should be_a(Net::HTTPResponse)
|
|
66
|
+
wsdl_response.body.should == WSDLFixture.authentication
|
|
81
67
|
end
|
|
82
68
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
69
|
+
it "executes a SOAP request and returns the Net::HTTP response" do
|
|
70
|
+
soap = Savon::SOAP.new
|
|
71
|
+
soap.endpoint = URI EndpointHelper.wsdl_endpoint
|
|
72
|
+
soap_response = @request.soap soap
|
|
86
73
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
end
|
|
74
|
+
soap_response.should be_a(Net::HTTPResponse)
|
|
75
|
+
soap_response.body.should == ResponseFixture.authentication
|
|
90
76
|
end
|
|
91
77
|
|
|
92
|
-
end
|
|
78
|
+
end
|
data/spec/savon/response_spec.rb
CHANGED
|
@@ -1,54 +1,40 @@
|
|
|
1
1
|
require "spec_helper"
|
|
2
2
|
|
|
3
3
|
describe Savon::Response do
|
|
4
|
-
before { @response =
|
|
4
|
+
before { @response = Savon::Response.new http_response_mock }
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
Savon::Response.
|
|
6
|
+
it "defaults to raises both Savon::SOAPFault and Savon::HTTPError" do
|
|
7
|
+
Savon::Response.raise_errors?.should be_true
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
Savon::Response.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
def http_error_response_instance
|
|
15
|
-
Savon::Response.new http_response_mock(404, "", "Not found")
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
describe "@raise_errors" do
|
|
19
|
-
it "defaults to true" do
|
|
20
|
-
Savon::Response.raise_errors?.should be_true
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
it "has accessor methods" do
|
|
24
|
-
Savon::Response.raise_errors = false
|
|
25
|
-
Savon::Response.raise_errors?.should == false
|
|
26
|
-
Savon::Response.raise_errors = true
|
|
27
|
-
end
|
|
10
|
+
it "has both getter and setter for whether to raise errors (global setting)" do
|
|
11
|
+
Savon::Response.raise_errors = false
|
|
12
|
+
Savon::Response.raise_errors?.should == false
|
|
13
|
+
Savon::Response.raise_errors = true
|
|
28
14
|
end
|
|
29
15
|
|
|
30
16
|
describe "initialize" do
|
|
31
17
|
it "expects a Net::HTTPResponse" do
|
|
32
|
-
|
|
18
|
+
Savon::Response.new http_response_mock
|
|
33
19
|
end
|
|
34
20
|
|
|
35
21
|
it "raises a Savon::SOAPFault in case of a SOAP fault" do
|
|
36
|
-
lambda {
|
|
22
|
+
lambda { savon_response_with :soap_fault }.should raise_error(Savon::SOAPFault)
|
|
37
23
|
end
|
|
38
24
|
|
|
39
25
|
it "does not raise a Savon::SOAPFault in case the default is turned off" do
|
|
40
26
|
Savon::Response.raise_errors = false
|
|
41
|
-
|
|
27
|
+
savon_response_with :soap_fault
|
|
42
28
|
Savon::Response.raise_errors = true
|
|
43
29
|
end
|
|
44
30
|
|
|
45
31
|
it "raises a Savon::HTTPError in case of an HTTP error" do
|
|
46
|
-
lambda {
|
|
32
|
+
lambda { savon_response_with :http_error }.should raise_error(Savon::HTTPError)
|
|
47
33
|
end
|
|
48
34
|
|
|
49
35
|
it "does not raise a Savon::HTTPError in case the default is turned off" do
|
|
50
36
|
Savon::Response.raise_errors = false
|
|
51
|
-
|
|
37
|
+
savon_response_with :http_error
|
|
52
38
|
Savon::Response.raise_errors = true
|
|
53
39
|
end
|
|
54
40
|
end
|
|
@@ -61,8 +47,7 @@ describe Savon::Response do
|
|
|
61
47
|
end
|
|
62
48
|
|
|
63
49
|
it "returns true in case of a SOAP fault" do
|
|
64
|
-
|
|
65
|
-
response.soap_fault?.should be_true
|
|
50
|
+
savon_response_with(:soap_fault).soap_fault?.should be_true
|
|
66
51
|
end
|
|
67
52
|
|
|
68
53
|
after { Savon::Response.raise_errors = true }
|
|
@@ -72,8 +57,13 @@ describe Savon::Response do
|
|
|
72
57
|
before { Savon::Response.raise_errors = false }
|
|
73
58
|
|
|
74
59
|
it "returns the SOAP fault message in case of a SOAP fault" do
|
|
75
|
-
|
|
76
|
-
|
|
60
|
+
savon_response_with(:soap_fault).soap_fault.
|
|
61
|
+
should == "(soap:Server) Fault occurred while processing."
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it "returns the SOAP fault message in case of a SOAP 1.2 fault" do
|
|
65
|
+
savon_response_with(:soap_fault12).soap_fault.
|
|
66
|
+
should == "(soap:Sender) Sender Timeout"
|
|
77
67
|
end
|
|
78
68
|
|
|
79
69
|
after { Savon::Response.raise_errors = true }
|
|
@@ -87,8 +77,7 @@ describe Savon::Response do
|
|
|
87
77
|
end
|
|
88
78
|
|
|
89
79
|
it "returns true in case of an HTTP error" do
|
|
90
|
-
|
|
91
|
-
response.http_error?.should be_true
|
|
80
|
+
savon_response_with(:http_error).http_error?.should be_true
|
|
92
81
|
end
|
|
93
82
|
|
|
94
83
|
after { Savon::Response.raise_errors = true }
|
|
@@ -98,36 +87,44 @@ describe Savon::Response do
|
|
|
98
87
|
before { Savon::Response.raise_errors = false }
|
|
99
88
|
|
|
100
89
|
it "returns the HTTP error message in case of an HTTP error" do
|
|
101
|
-
|
|
102
|
-
response.http_error.should == "Not found (404)"
|
|
90
|
+
savon_response_with(:http_error).http_error.should == "Not found (404)"
|
|
103
91
|
end
|
|
104
92
|
|
|
105
93
|
after { Savon::Response.raise_errors = true }
|
|
106
94
|
end
|
|
107
95
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
end
|
|
96
|
+
it "should return the SOAP response body as a Hash" do
|
|
97
|
+
@response.to_hash[:authenticate_response][:return].should ==
|
|
98
|
+
ResponseFixture.authentication(:to_hash)
|
|
112
99
|
end
|
|
113
100
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
101
|
+
it "should return a Hash for a SOAP multiRef response" do
|
|
102
|
+
@response = Savon::Response.new http_response_mock(200, ResponseFixture.multi_ref, "OK")
|
|
103
|
+
|
|
104
|
+
@response.to_hash[:list_response].should be_a(Hash)
|
|
105
|
+
@response.to_hash[:multi_ref].should be_an(Array)
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
it "should return the raw SOAP response body" do
|
|
109
|
+
@response.to_xml.should == ResponseFixture.authentication
|
|
110
|
+
@response.to_s.should == ResponseFixture.authentication
|
|
118
111
|
end
|
|
119
112
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
113
|
+
def savon_response_with(error_type)
|
|
114
|
+
mock = case error_type
|
|
115
|
+
when :soap_fault then http_response_mock 200, ResponseFixture.soap_fault
|
|
116
|
+
when :soap_fault12 then http_response_mock 200, ResponseFixture.soap_fault12
|
|
117
|
+
when :http_error then http_response_mock 404, "", "Not found"
|
|
123
118
|
end
|
|
119
|
+
Savon::Response.new mock
|
|
124
120
|
end
|
|
125
121
|
|
|
126
|
-
def http_response_mock(code = 200, body =
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
122
|
+
def http_response_mock(code = 200, body = nil, message = "OK")
|
|
123
|
+
body ||= ResponseFixture.authentication
|
|
124
|
+
mock = mock "Net::HTTPResponse"
|
|
125
|
+
mock.stubs :code => code.to_s, :message => message,
|
|
126
|
+
:content_type => "text/html", :body => body
|
|
127
|
+
mock
|
|
131
128
|
end
|
|
132
129
|
|
|
133
|
-
end
|
|
130
|
+
end
|
data/spec/savon/savon_spec.rb
CHANGED
|
@@ -2,29 +2,22 @@ require "spec_helper"
|
|
|
2
2
|
|
|
3
3
|
describe Savon do
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Savon::SOAPVersions.should_not be_empty
|
|
9
|
-
end
|
|
5
|
+
it "contains an Array of supported SOAP versions" do
|
|
6
|
+
Savon::SOAPVersions.should be_an(Array)
|
|
7
|
+
Savon::SOAPVersions.should_not be_empty
|
|
10
8
|
end
|
|
11
9
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
Savon::SOAPDateTimeFormat.should_not be_empty
|
|
10
|
+
it "contains the xs:dateTime format" do
|
|
11
|
+
Savon::SOAPDateTimeFormat.should be_a(String)
|
|
12
|
+
Savon::SOAPDateTimeFormat.should_not be_empty
|
|
16
13
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
end
|
|
14
|
+
DateTime.new(2012, 03, 22, 16, 22, 33).strftime(Savon::SOAPDateTimeFormat).
|
|
15
|
+
should == "2012-03-22T16:22:33"
|
|
20
16
|
end
|
|
21
17
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
(Savon::SOAPDateTimeRegexp === UserFixture.datetime_string).
|
|
26
|
-
should be_true
|
|
27
|
-
end
|
|
18
|
+
it "contains a Regexp matching the xs:dateTime format" do
|
|
19
|
+
Savon::SOAPDateTimeRegexp.should be_a(Regexp)
|
|
20
|
+
(Savon::SOAPDateTimeRegexp === "2012-03-22T16:22:33").should be_true
|
|
28
21
|
end
|
|
29
22
|
|
|
30
|
-
end
|
|
23
|
+
end
|
data/spec/savon/soap_spec.rb
CHANGED
|
@@ -1,140 +1,131 @@
|
|
|
1
1
|
require "spec_helper"
|
|
2
2
|
|
|
3
3
|
describe Savon::SOAP do
|
|
4
|
-
before
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Savon::SOAP.new UserFixture.soap_actions[:find_user]
|
|
4
|
+
before do
|
|
5
|
+
@soap = Savon::SOAP.new
|
|
6
|
+
@soap.action = WSDLFixture.authentication(:operations)[:authenticate][:action]
|
|
8
7
|
end
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
Savon::
|
|
13
|
-
|
|
14
|
-
Savon::SOAP::SOAPNamespace[soap_version].should_not be_empty
|
|
15
|
-
end
|
|
9
|
+
it "contains the SOAP namespace for each supported SOAP version" do
|
|
10
|
+
Savon::SOAPVersions.each do |soap_version|
|
|
11
|
+
Savon::SOAP::SOAPNamespace[soap_version].should be_a(String)
|
|
12
|
+
Savon::SOAP::SOAPNamespace[soap_version].should_not be_empty
|
|
16
13
|
end
|
|
17
14
|
end
|
|
18
15
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
Savon::
|
|
22
|
-
|
|
23
|
-
Savon::SOAP::ContentType[soap_version].should_not be_empty
|
|
24
|
-
end
|
|
16
|
+
it "contains the Content-Types for each supported SOAP version" do
|
|
17
|
+
Savon::SOAPVersions.each do |soap_version|
|
|
18
|
+
Savon::SOAP::ContentType[soap_version].should be_a(String)
|
|
19
|
+
Savon::SOAP::ContentType[soap_version].should_not be_empty
|
|
25
20
|
end
|
|
26
21
|
end
|
|
27
22
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
Savon::SOAP.version.should == 1
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
it "has accessor methods" do
|
|
34
|
-
[2, 1].each do |soap_version|
|
|
35
|
-
Savon::SOAP.version = soap_version
|
|
36
|
-
Savon::SOAP.version.should == soap_version
|
|
37
|
-
end
|
|
38
|
-
end
|
|
23
|
+
it "defaults to SOAP 1.1" do
|
|
24
|
+
Savon::SOAP.version.should == 1
|
|
39
25
|
end
|
|
40
26
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
27
|
+
it "has both getter and setter for the SOAP version to use (global setting)" do
|
|
28
|
+
[2, 1].each do |soap_version|
|
|
29
|
+
Savon::SOAP.version = soap_version
|
|
30
|
+
Savon::SOAP.version.should == soap_version
|
|
44
31
|
end
|
|
45
32
|
end
|
|
46
33
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
@soap.wsse = Savon::WSSE.new
|
|
50
|
-
end
|
|
34
|
+
it "has a setter for the Savon::WSSE" do
|
|
35
|
+
@soap.wsse = Savon::WSSE.new
|
|
51
36
|
end
|
|
52
37
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
@soap.action.should == UserFixture.soap_actions[:find_user][:name]
|
|
38
|
+
it "is has both getter and setter for the SOAP action" do
|
|
39
|
+
@soap.action.should == WSDLFixture.authentication(:operations)[:authenticate][:action]
|
|
56
40
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
@soap.action.should == action
|
|
60
|
-
end
|
|
41
|
+
@soap.action = "someAction"
|
|
42
|
+
@soap.action.should == "someAction"
|
|
61
43
|
end
|
|
62
44
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
@soap.header.should be_empty
|
|
45
|
+
it "has a setter for the SOAP input" do
|
|
46
|
+
@soap.input = "FindUserRequest"
|
|
47
|
+
end
|
|
67
48
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
49
|
+
it "has both getter and setter for the SOAP header" do
|
|
50
|
+
@soap.header.should be_a(Hash)
|
|
51
|
+
@soap.header.should be_empty
|
|
52
|
+
|
|
53
|
+
@soap.header = { "specialAuthKey" => "secret" }
|
|
54
|
+
@soap.header.should == { "specialAuthKey" => "secret" }
|
|
72
55
|
end
|
|
73
56
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
57
|
+
it "has a getter for the SOAP body, expecting a Hash or an XML String" do
|
|
58
|
+
@soap.body = { :id => 666 }
|
|
59
|
+
@soap.body = "<id>666</id>"
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it "has a setter for specifying a Hash of namespaces" do
|
|
63
|
+
namespaces = { "xmlns:env" => "http://example.com" }
|
|
64
|
+
@soap.namespaces = namespaces
|
|
65
|
+
@soap.namespaces.should == namespaces
|
|
79
66
|
end
|
|
80
67
|
|
|
81
|
-
describe "namespaces" do
|
|
82
|
-
it "defaults to
|
|
83
|
-
soap
|
|
84
|
-
soap.namespaces.should == { "xmlns:env" => Savon::SOAP::SOAPNamespace[1] }
|
|
68
|
+
describe "has a getter for namespaces" do
|
|
69
|
+
it "which defaults to include the SOAP 1.1 namespace" do
|
|
70
|
+
@soap.namespaces.should == { "xmlns:env" => Savon::SOAP::SOAPNamespace[1] }
|
|
85
71
|
end
|
|
86
72
|
|
|
87
|
-
it "contains the
|
|
88
|
-
soap =
|
|
89
|
-
soap.
|
|
90
|
-
soap.namespaces.should == { "xmlns:env" => Savon::SOAP::SOAPNamespace[2] }
|
|
73
|
+
it "which contains the SOAP 1.2 namespace if specified" do
|
|
74
|
+
@soap.version = 2
|
|
75
|
+
@soap.namespaces.should == { "xmlns:env" => Savon::SOAP::SOAPNamespace[2] }
|
|
91
76
|
end
|
|
92
77
|
end
|
|
93
78
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
soap = some_soap_instance
|
|
97
|
-
soap.version = 2
|
|
98
|
-
soap.version.should == 2
|
|
99
|
-
end
|
|
79
|
+
it "has a convenience method for setting the 'xmlns:wsdl' namespace" do
|
|
80
|
+
@soap.namespaces.should == { "xmlns:env" => "http://schemas.xmlsoap.org/soap/envelope/" }
|
|
100
81
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
82
|
+
@soap.namespace = "http://example.com"
|
|
83
|
+
@soap.namespaces.should include("xmlns:env" => "http://schemas.xmlsoap.org/soap/envelope/")
|
|
84
|
+
@soap.namespaces.should include("xmlns:wsdl" => "http://example.com")
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
it "has both getter and setter for the SOAP endpoint" do
|
|
88
|
+
@soap.endpoint.should be_nil
|
|
89
|
+
|
|
90
|
+
soap_endpoint = URI EndpointHelper.soap_endpoint
|
|
91
|
+
@soap.endpoint = soap_endpoint
|
|
92
|
+
@soap.endpoint.should == soap_endpoint
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
it "has a getter for the SOAP version to use which defaults to SOAP 1.1" do
|
|
96
|
+
@soap.version.should == Savon::SOAP.version
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
it "has a setter for specifying the SOAP version to use" do
|
|
100
|
+
@soap.version = 2
|
|
101
|
+
@soap.version.should == 2
|
|
104
102
|
end
|
|
105
103
|
|
|
106
104
|
describe "to_xml" do
|
|
107
|
-
|
|
105
|
+
after { Savon::SOAP.version = 1 }
|
|
108
106
|
|
|
109
107
|
it "returns the XML for a SOAP request" do
|
|
110
|
-
soap =
|
|
111
|
-
soap.
|
|
112
|
-
|
|
113
|
-
soap.to_xml.should
|
|
108
|
+
@soap.namespaces["xmlns:wsdl"] = "http://v1_0.ws.auth.order.example.com/"
|
|
109
|
+
@soap.body = { :id => 666 }
|
|
110
|
+
|
|
111
|
+
@soap.to_xml.should include('xmlns:wsdl="http://v1_0.ws.auth.order.example.com/"')
|
|
112
|
+
@soap.to_xml.should include('xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"')
|
|
113
|
+
@soap.to_xml.should include('<wsdl:authenticate><id>666</id></wsdl:authenticate>')
|
|
114
114
|
end
|
|
115
115
|
|
|
116
116
|
it "caches the XML, returning the same Object every time" do
|
|
117
117
|
@soap.to_xml.object_id.should == @soap.to_xml.object_id
|
|
118
118
|
end
|
|
119
119
|
|
|
120
|
-
it "uses the SOAP namespace for the SOAP version
|
|
121
|
-
soap =
|
|
122
|
-
soap.
|
|
123
|
-
soap.to_xml.should include Savon::SOAP::SOAPNamespace[2]
|
|
120
|
+
it "uses the SOAP namespace for the specified SOAP version" do
|
|
121
|
+
@soap.version = 2
|
|
122
|
+
@soap.to_xml.should include(Savon::SOAP::SOAPNamespace[2])
|
|
124
123
|
end
|
|
125
124
|
|
|
126
125
|
it "uses the SOAP namespace for the default SOAP version otherwise" do
|
|
127
126
|
Savon::SOAP.version = 2
|
|
128
|
-
@soap.to_xml.should include
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
def soap_body
|
|
132
|
-
"<env:Envelope xmlns:wsdl=\"http://v1_0.ws.user.example.com\" " <<
|
|
133
|
-
"xmlns:env=\"http://schemas.xmlsoap.org/soap/envelope/\">" <<
|
|
134
|
-
"<env:Header></env:Header>" <<
|
|
135
|
-
"<env:Body><wsdl:findUser><id>666</id></wsdl:findUser></env:Body>" <<
|
|
136
|
-
"</env:Envelope>"
|
|
127
|
+
@soap.to_xml.should include(Savon::SOAP::SOAPNamespace[2])
|
|
137
128
|
end
|
|
138
129
|
end
|
|
139
130
|
|
|
140
|
-
end
|
|
131
|
+
end
|