savon 1.1.0 → 1.2.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.md +127 -67
- data/lib/savon/client.rb +62 -83
- data/lib/savon/http/error.rb +1 -1
- data/lib/savon/soap/request_builder.rb +205 -0
- data/lib/savon/soap/xml.rb +1 -1
- data/lib/savon/version.rb +1 -1
- data/spec/fixtures/wsdl/multiple_namespaces.xml +31 -0
- data/spec/integration/request_spec.rb +50 -11
- data/spec/savon/client_spec.rb +181 -104
- data/spec/savon/http/error_spec.rb +1 -1
- data/spec/savon/soap/fault_spec.rb +1 -1
- data/spec/savon/soap/request_builder_spec.rb +207 -0
- metadata +42 -40
- data/lib/savon/wasabi/document.rb +0 -47
- data/spec/savon/wasabi/document_spec.rb +0 -58
@@ -1,47 +0,0 @@
|
|
1
|
-
require "wasabi"
|
2
|
-
require "httpi/request"
|
3
|
-
|
4
|
-
module Savon
|
5
|
-
module Wasabi
|
6
|
-
|
7
|
-
# = Savon::Wasabi::Document
|
8
|
-
#
|
9
|
-
# Extends the document handling of the <tt>Wasabi::Document</tt> by
|
10
|
-
# adding support for remote and local WSDL documents.
|
11
|
-
class Document < ::Wasabi::Document
|
12
|
-
|
13
|
-
# Hooks into Wasabi and extends its document handling.
|
14
|
-
def xml
|
15
|
-
@xml ||= document.kind_of?(String) ? resolve_document : document
|
16
|
-
end
|
17
|
-
|
18
|
-
# Sets the <tt>HTTPI::Request</tt> for remote WSDL documents.
|
19
|
-
attr_writer :request
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
# Sets up and returns the <tt>HTTPI::Request</tt>.
|
24
|
-
def request
|
25
|
-
@request ||= HTTPI::Request.new
|
26
|
-
@request.url = document
|
27
|
-
@request
|
28
|
-
end
|
29
|
-
|
30
|
-
# Resolves and returns the raw WSDL document.
|
31
|
-
def resolve_document
|
32
|
-
case document
|
33
|
-
when /^http[s]?:/ then
|
34
|
-
response = HTTPI.get(request)
|
35
|
-
if response.error?
|
36
|
-
raise Savon::HTTP::Error.new(response)
|
37
|
-
else
|
38
|
-
response.body
|
39
|
-
end
|
40
|
-
when /^</ then document
|
41
|
-
else File.read(document)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Savon::Wasabi::Document do
|
4
|
-
|
5
|
-
context "with a remote document" do
|
6
|
-
before do
|
7
|
-
response = HTTPI::Response.new 200, {}, Fixture.wsdl(:authentication)
|
8
|
-
HTTPI.stubs(:get).returns(response)
|
9
|
-
end
|
10
|
-
|
11
|
-
it "should resolve via HTTP" do
|
12
|
-
wsdl = Savon::Wasabi::Document.new("http://example.com?wsdl")
|
13
|
-
wsdl.xml.should == Fixture.wsdl(:authentication)
|
14
|
-
end
|
15
|
-
|
16
|
-
it "should resolve via HTTPS" do
|
17
|
-
wsdl = Savon::Wasabi::Document.new("https://example.com?wsdl")
|
18
|
-
wsdl.xml.should == Fixture.wsdl(:authentication)
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
context "with an inaccessible remote document" do
|
24
|
-
before do
|
25
|
-
response = HTTPI::Response.new 401, {}, Fixture.wsdl(:authentication)
|
26
|
-
HTTPI.stubs(:get).returns(response)
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should raise an error when authentication fails" do
|
30
|
-
wsdl = Savon::Wasabi::Document.new("http://example.com?wsdl")
|
31
|
-
expect { wsdl.xml }.to raise_error(Savon::HTTP::Error)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
context "with a local document" do
|
36
|
-
before do
|
37
|
-
HTTPI.expects(:get).never
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should read the file" do
|
41
|
-
wsdl = Savon::Wasabi::Document.new("spec/fixtures/wsdl/authentication.xml")
|
42
|
-
wsdl.xml.should == Fixture.wsdl(:authentication)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
context "with raw XML" do
|
47
|
-
before do
|
48
|
-
HTTPI.expects(:get).never
|
49
|
-
File.expects(:read).never
|
50
|
-
end
|
51
|
-
|
52
|
-
it "should use the raw XML" do
|
53
|
-
wsdl = Savon::Wasabi::Document.new Fixture.wsdl(:authentication)
|
54
|
-
wsdl.xml.should == Fixture.wsdl(:authentication)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
end
|