wasabi 1.0.0 → 2.0.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 +6 -1
- data/lib/wasabi/core_ext/object.rb +14 -0
- data/lib/wasabi/document.rb +33 -2
- data/lib/wasabi/parser.rb +61 -10
- data/lib/wasabi/version.rb +1 -1
- data/spec/fixtures/lower_camel.xml +52 -0
- data/spec/fixtures/multiple_namespaces.xml +61 -0
- data/spec/fixtures/multiple_types.xml +60 -0
- data/spec/wasabi/core_ext/object_spec.rb +19 -0
- data/spec/wasabi/document/multiple_namespaces_spec.rb +35 -0
- data/spec/wasabi/parser/multiple_namespaces_spec.rb +36 -0
- data/spec/wasabi/parser/no_namespace_spec.rb +23 -0
- data/spec/wasabi/parser/no_target_namespace_spec.rb +36 -0
- metadata +21 -4
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
+
## 2.0.0 (2011-07-07)
|
2
|
+
|
3
|
+
* Feature: Wasabi can now parse type definitions and namespaces.
|
4
|
+
Thanks to [jkingdon](https://github.com/jkingdon) for implementing this.
|
5
|
+
|
1
6
|
## 1.0.0 (2011-07-03)
|
2
7
|
|
3
8
|
* Initial version extracted from the [Savon](http://rubygems.org/gems/savon) library.
|
4
|
-
Use it to build your own SOAP client and help to improve it!
|
9
|
+
Use it to build your own SOAP client and help to improve it!
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Wasabi
|
2
|
+
module CoreExt
|
3
|
+
module Object
|
4
|
+
|
5
|
+
# Returns +true+ if the Object is nil, false or empty. Implementation from ActiveSupport.
|
6
|
+
def blank?
|
7
|
+
respond_to?(:empty?) ? empty? : !self
|
8
|
+
end unless method_defined?(:blank?)
|
9
|
+
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
Object.send :include, Wasabi::CoreExt::Object
|
data/lib/wasabi/document.rb
CHANGED
@@ -61,19 +61,50 @@ module Wasabi
|
|
61
61
|
@operations ||= parser.operations
|
62
62
|
end
|
63
63
|
|
64
|
+
def type_namespaces
|
65
|
+
@type_namespaces ||= begin
|
66
|
+
namespaces = []
|
67
|
+
parser.types.each do |type, info|
|
68
|
+
namespaces << [[type], info[:namespace]]
|
69
|
+
(info.keys - [:namespace]).each { |field| namespaces << [[type, field], info[:namespace]] }
|
70
|
+
end if document?
|
71
|
+
namespaces
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def type_definitions
|
76
|
+
@type_definitions ||= begin
|
77
|
+
result = []
|
78
|
+
parser.types.each do |type, info|
|
79
|
+
(info.keys - [:namespace]).each do |field|
|
80
|
+
field_type = info[field][:type]
|
81
|
+
tag, namespace = field_type.split(":").reverse
|
82
|
+
result << [[type, field], tag] if user_defined(namespace)
|
83
|
+
end
|
84
|
+
end if document?
|
85
|
+
result
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
# Returns whether the given +namespace+ was defined manually.
|
90
|
+
def user_defined(namespace)
|
91
|
+
uri = parser.namespaces[namespace]
|
92
|
+
!(uri =~ %r{^http://schemas.xmlsoap.org} || uri =~ %r{^http://www.w3.org})
|
93
|
+
end
|
94
|
+
|
64
95
|
# Returns the raw WSDL document.
|
65
96
|
# Can be used as a hook to extend the library.
|
66
97
|
def xml
|
67
98
|
@xml ||= document
|
68
99
|
end
|
69
100
|
|
70
|
-
private
|
71
|
-
|
72
101
|
# Parses the WSDL document and returns the <tt>Wasabi::Parser</tt>.
|
73
102
|
def parser
|
74
103
|
@parser ||= guard_parse && parse
|
75
104
|
end
|
76
105
|
|
106
|
+
private
|
107
|
+
|
77
108
|
# Raises an error if the WSDL document is missing.
|
78
109
|
def guard_parse
|
79
110
|
return true if xml.kind_of?(String)
|
data/lib/wasabi/parser.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "uri"
|
2
|
+
require "wasabi/core_ext/object"
|
2
3
|
require "wasabi/core_ext/string"
|
3
4
|
|
4
5
|
module Wasabi
|
@@ -8,30 +9,37 @@ module Wasabi
|
|
8
9
|
# Parses WSDL documents and remembers their important parts.
|
9
10
|
class Parser
|
10
11
|
|
11
|
-
def initialize(
|
12
|
-
@document =
|
13
|
-
@path = []
|
12
|
+
def initialize(nokogiri_document)
|
13
|
+
@document = nokogiri_document
|
14
14
|
@operations = {}
|
15
15
|
@namespaces = {}
|
16
|
+
@types = {}
|
16
17
|
@element_form_default = :unqualified
|
17
18
|
end
|
18
19
|
|
19
|
-
# Returns the SOAP endpoint.
|
20
|
-
attr_reader :endpoint
|
21
|
-
|
22
20
|
# Returns the target namespace.
|
23
21
|
attr_reader :namespace
|
24
22
|
|
23
|
+
# Returns a map from namespace identifier to namespace URI.
|
24
|
+
attr_reader :namespaces
|
25
|
+
|
25
26
|
# Returns the SOAP operations.
|
26
27
|
attr_reader :operations
|
27
28
|
|
28
|
-
# Returns
|
29
|
+
# Returns a map from a type name to a Hash with type information.
|
30
|
+
attr_reader :types
|
31
|
+
|
32
|
+
# Returns the SOAP endpoint.
|
33
|
+
attr_reader :endpoint
|
34
|
+
|
35
|
+
# Returns the elementFormDefault value.
|
29
36
|
attr_reader :element_form_default
|
30
37
|
|
31
38
|
def parse
|
32
39
|
parse_namespaces
|
33
40
|
parse_endpoint
|
34
41
|
parse_operations
|
42
|
+
parse_types
|
35
43
|
end
|
36
44
|
|
37
45
|
def parse_namespaces
|
@@ -45,6 +53,10 @@ module Wasabi
|
|
45
53
|
"s0:definitions/@targetNamespace",
|
46
54
|
"s0" => "http://schemas.xmlsoap.org/wsdl/")
|
47
55
|
@namespace = namespace.to_s if namespace
|
56
|
+
|
57
|
+
@namespaces = @document.collect_namespaces.inject({}) do |result, (key, value)|
|
58
|
+
result.merge(key.gsub(/xmlns:/, '') => value)
|
59
|
+
end
|
48
60
|
end
|
49
61
|
|
50
62
|
def parse_endpoint
|
@@ -64,7 +76,6 @@ module Wasabi
|
|
64
76
|
operations = @document.xpath(
|
65
77
|
"s0:definitions/s0:binding/s0:operation",
|
66
78
|
"s0" => "http://schemas.xmlsoap.org/wsdl/")
|
67
|
-
|
68
79
|
operations.each do |operation|
|
69
80
|
name = operation.attribute("name").to_s
|
70
81
|
|
@@ -78,8 +89,8 @@ module Wasabi
|
|
78
89
|
if soap_action
|
79
90
|
soap_action = soap_action.to_s
|
80
91
|
|
81
|
-
action = soap_action
|
82
|
-
input =
|
92
|
+
action = soap_action.blank? ? name : soap_action
|
93
|
+
input = name.blank? ? action.split("/").last : name
|
83
94
|
|
84
95
|
@operations[input.snakecase.to_sym] =
|
85
96
|
{ :action => action, :input => input }
|
@@ -90,5 +101,45 @@ module Wasabi
|
|
90
101
|
end
|
91
102
|
end
|
92
103
|
|
104
|
+
def parse_types
|
105
|
+
@document.xpath(
|
106
|
+
"s0:definitions/s0:types/xs:schema/xs:element[@name]",
|
107
|
+
"s0" => "http://schemas.xmlsoap.org/wsdl/",
|
108
|
+
"xs" => "http://www.w3.org/2001/XMLSchema"
|
109
|
+
).each do |type|
|
110
|
+
process_type(type.at_xpath('./xs:complexType',
|
111
|
+
"xs" => "http://www.w3.org/2001/XMLSchema"
|
112
|
+
), type.attribute('name').to_s)
|
113
|
+
end
|
114
|
+
|
115
|
+
@document.xpath(
|
116
|
+
"s0:definitions/s0:types/xs:schema/xs:complexType[@name]",
|
117
|
+
"s0" => "http://schemas.xmlsoap.org/wsdl/",
|
118
|
+
"xs" => "http://www.w3.org/2001/XMLSchema"
|
119
|
+
).each do |type|
|
120
|
+
process_type(type, type.attribute('name').to_s)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def process_type(type, name)
|
125
|
+
return unless type
|
126
|
+
@types[name] ||= { :namespace => find_namespace(type) }
|
127
|
+
|
128
|
+
type.xpath("./xs:sequence/xs:element",
|
129
|
+
"xs" => "http://www.w3.org/2001/XMLSchema"
|
130
|
+
).each do |inner_element|
|
131
|
+
@types[name][inner_element.attribute('name').to_s] = {
|
132
|
+
:type => inner_element.attribute('type').to_s
|
133
|
+
}
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
def find_namespace(type)
|
138
|
+
schema_namespace = type.at_xpath("ancestor::xs:schema/@targetNamespace",
|
139
|
+
"xs" => "http://www.w3.org/2001/XMLSchema"
|
140
|
+
)
|
141
|
+
schema_namespace ? schema_namespace.to_s : @namespace
|
142
|
+
end
|
143
|
+
|
93
144
|
end
|
94
145
|
end
|
data/lib/wasabi/version.rb
CHANGED
@@ -0,0 +1,52 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<definitions
|
3
|
+
xmlns="http://schemas.xmlsoap.org/wsdl/"
|
4
|
+
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
|
5
|
+
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
|
6
|
+
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
|
7
|
+
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
|
8
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
9
|
+
xmlns:s="http://www.w3.org/2001/XMLSchema"
|
10
|
+
xmlns:actions="http://example.com/actions"
|
11
|
+
targetNamespace="http://example.com/topLevelNamespace">
|
12
|
+
<types>
|
13
|
+
<s:schema elementFormDefault="qualified" targetNamespace="http://example.com/actions">
|
14
|
+
<s:element name="Save">
|
15
|
+
<s:complexType>
|
16
|
+
<s:sequence>
|
17
|
+
<s:element name="lowerCamel" type="s:string"/>
|
18
|
+
</s:sequence>
|
19
|
+
</s:complexType>
|
20
|
+
</s:element>
|
21
|
+
</s:schema>
|
22
|
+
</types>
|
23
|
+
<message name="SaveSoapIn">
|
24
|
+
<part name="parameters" element="actions:Save"/>
|
25
|
+
</message>
|
26
|
+
<message name="SaveSoapOut">
|
27
|
+
<part name="parameters" element="actions:SaveResponse"/>
|
28
|
+
</message>
|
29
|
+
<portType name="ArticleSoap">
|
30
|
+
<operation name="Save">
|
31
|
+
<input message="actions:SaveSoapIn"/>
|
32
|
+
<output message="actions:SaveSoapOut"/>
|
33
|
+
</operation>
|
34
|
+
</portType>
|
35
|
+
<binding name="ArticleSoap" type="actions:ArticleSoap">
|
36
|
+
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
|
37
|
+
<operation name="Save">
|
38
|
+
<soap:operation soapAction="http://example.com/actions.Save" style="document"/>
|
39
|
+
<input>
|
40
|
+
<soap:body use="literal"/>
|
41
|
+
</input>
|
42
|
+
<output>
|
43
|
+
<soap:body use="literal"/>
|
44
|
+
</output>
|
45
|
+
</operation>
|
46
|
+
</binding>
|
47
|
+
<service name="StudyMDL">
|
48
|
+
<port name="StudyMDLSoap" binding="actions:StudyMDLSoap">
|
49
|
+
<soap:address location="http://example.com:1234/soap"/>
|
50
|
+
</port>
|
51
|
+
</service>
|
52
|
+
</definitions>
|
@@ -0,0 +1,61 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<definitions
|
3
|
+
xmlns="http://schemas.xmlsoap.org/wsdl/"
|
4
|
+
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
|
5
|
+
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
|
6
|
+
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
|
7
|
+
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
|
8
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
9
|
+
xmlns:s="http://www.w3.org/2001/XMLSchema"
|
10
|
+
xmlns:article="http://example.com/article"
|
11
|
+
xmlns:actions="http://example.com/actions"
|
12
|
+
targetNamespace="http://example.com/actions">
|
13
|
+
<types>
|
14
|
+
<s:schema elementFormDefault="qualified" targetNamespace="http://example.com/actions">
|
15
|
+
<s:element name="Save">
|
16
|
+
<s:complexType>
|
17
|
+
<s:sequence>
|
18
|
+
<s:element name="article" type="article:Article"/>
|
19
|
+
</s:sequence>
|
20
|
+
</s:complexType>
|
21
|
+
</s:element>
|
22
|
+
</s:schema>
|
23
|
+
<s:schema elementFormDefault="qualified" targetNamespace="http://example.com/article">
|
24
|
+
<s:complexType name="Article">
|
25
|
+
<s:sequence>
|
26
|
+
<s:element minOccurs="0" name="Author" type="s:string"/>
|
27
|
+
<s:element minOccurs="0" name="Title" type="s:string"/>
|
28
|
+
</s:sequence>
|
29
|
+
</s:complexType>
|
30
|
+
</s:schema>
|
31
|
+
</types>
|
32
|
+
<message name="SaveSoapIn">
|
33
|
+
<part name="parameters" element="actions:Save"/>
|
34
|
+
</message>
|
35
|
+
<message name="SaveSoapOut">
|
36
|
+
<part name="parameters" element="actions:SaveResponse"/>
|
37
|
+
</message>
|
38
|
+
<portType name="ArticleSoap">
|
39
|
+
<operation name="Save">
|
40
|
+
<input message="actions:SaveSoapIn"/>
|
41
|
+
<output message="actions:SaveSoapOut"/>
|
42
|
+
</operation>
|
43
|
+
</portType>
|
44
|
+
<binding name="ArticleSoap" type="actions:ArticleSoap">
|
45
|
+
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
|
46
|
+
<operation name="Save">
|
47
|
+
<soap:operation soapAction="http://example.com/actions.Save" style="document"/>
|
48
|
+
<input>
|
49
|
+
<soap:body use="literal"/>
|
50
|
+
</input>
|
51
|
+
<output>
|
52
|
+
<soap:body use="literal"/>
|
53
|
+
</output>
|
54
|
+
</operation>
|
55
|
+
</binding>
|
56
|
+
<service name="StudyMDL">
|
57
|
+
<port name="StudyMDLSoap" binding="actions:StudyMDLSoap">
|
58
|
+
<soap:address location="http://example.com:1234/soap"/>
|
59
|
+
</port>
|
60
|
+
</service>
|
61
|
+
</definitions>
|
@@ -0,0 +1,60 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<definitions
|
3
|
+
xmlns="http://schemas.xmlsoap.org/wsdl/"
|
4
|
+
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
|
5
|
+
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
|
6
|
+
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
|
7
|
+
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
|
8
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
9
|
+
xmlns:s="http://www.w3.org/2001/XMLSchema"
|
10
|
+
xmlns:article="http://example.com/article"
|
11
|
+
xmlns:actions="http://example.com/actions"
|
12
|
+
targetNamespace="http://example.com/actions">
|
13
|
+
<types>
|
14
|
+
<s:schema elementFormDefault="qualified" targetNamespace="http://example.com/actions">
|
15
|
+
<s:element name="Save">
|
16
|
+
<s:complexType>
|
17
|
+
<s:sequence>
|
18
|
+
<s:element name="article" type="s:string"/>
|
19
|
+
</s:sequence>
|
20
|
+
</s:complexType>
|
21
|
+
</s:element>
|
22
|
+
<s:element name="Get">
|
23
|
+
<s:complexType>
|
24
|
+
<s:sequence>
|
25
|
+
<s:element name="articleId" type="s:long"/>
|
26
|
+
</s:sequence>
|
27
|
+
</s:complexType>
|
28
|
+
</s:element>
|
29
|
+
</s:schema>
|
30
|
+
</types>
|
31
|
+
<message name="SaveSoapIn">
|
32
|
+
<part name="parameters" element="actions:Save"/>
|
33
|
+
</message>
|
34
|
+
<message name="SaveSoapOut">
|
35
|
+
<part name="parameters" element="actions:SaveResponse"/>
|
36
|
+
</message>
|
37
|
+
<portType name="ArticleSoap">
|
38
|
+
<operation name="Save">
|
39
|
+
<input message="actions:SaveSoapIn"/>
|
40
|
+
<output message="actions:SaveSoapOut"/>
|
41
|
+
</operation>
|
42
|
+
</portType>
|
43
|
+
<binding name="ArticleSoap" type="actions:ArticleSoap">
|
44
|
+
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
|
45
|
+
<operation name="Save">
|
46
|
+
<soap:operation soapAction="http://example.com/actions.Save" style="document"/>
|
47
|
+
<input>
|
48
|
+
<soap:body use="literal"/>
|
49
|
+
</input>
|
50
|
+
<output>
|
51
|
+
<soap:body use="literal"/>
|
52
|
+
</output>
|
53
|
+
</operation>
|
54
|
+
</binding>
|
55
|
+
<service name="StudyMDL">
|
56
|
+
<port name="StudyMDLSoap" binding="actions:StudyMDLSoap">
|
57
|
+
<soap:address location="http://example.com:1234/soap"/>
|
58
|
+
</port>
|
59
|
+
</service>
|
60
|
+
</definitions>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Object do
|
4
|
+
|
5
|
+
describe "blank?" do
|
6
|
+
it "returns true for Objects perceived to be blank" do
|
7
|
+
["", false, nil, [], {}].each do |object|
|
8
|
+
object.should be_blank
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
it "returns false for every other Object" do
|
13
|
+
["!blank", true, [:a], {:a => "b"}].each do |object|
|
14
|
+
object.should_not be_blank
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Wasabi::Document do
|
4
|
+
context "with: multiple_namespaces.xml" do
|
5
|
+
|
6
|
+
subject { Wasabi::Document.new fixture(:multiple_namespaces) }
|
7
|
+
|
8
|
+
its(:namespace) { should == "http://example.com/actions" }
|
9
|
+
|
10
|
+
its(:endpoint) { should == URI("http://example.com:1234/soap") }
|
11
|
+
|
12
|
+
its(:element_form_default) { should == :qualified }
|
13
|
+
|
14
|
+
it { should have(1).operations }
|
15
|
+
|
16
|
+
its(:operations) do
|
17
|
+
should == { :save => { :input => "Save", :action => "http://example.com/actions.Save" } }
|
18
|
+
end
|
19
|
+
|
20
|
+
its(:type_namespaces) do
|
21
|
+
should =~ [
|
22
|
+
[["Save"], "http://example.com/actions"],
|
23
|
+
[["Save", "article"], "http://example.com/actions"],
|
24
|
+
[["Article"], "http://example.com/article"],
|
25
|
+
[["Article", "Author"], "http://example.com/article"],
|
26
|
+
[["Article", "Title"], "http://example.com/article"]
|
27
|
+
]
|
28
|
+
end
|
29
|
+
|
30
|
+
its(:type_definitions) do
|
31
|
+
should =~ [ [["Save", "article"], "Article"] ]
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Wasabi::Parser do
|
4
|
+
context "with: multiple_namespaces.xml" do
|
5
|
+
|
6
|
+
subject do
|
7
|
+
parser = Wasabi::Parser.new Nokogiri::XML(xml)
|
8
|
+
parser.parse
|
9
|
+
parser
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:xml) { fixture(:multiple_namespaces) }
|
13
|
+
|
14
|
+
it "lists the types" do
|
15
|
+
subject.types.keys.sort.should == ["Article", "Save"]
|
16
|
+
end
|
17
|
+
|
18
|
+
it "records the namespace for each type" do
|
19
|
+
subject.types["Save"][:namespace].should == "http://example.com/actions"
|
20
|
+
end
|
21
|
+
|
22
|
+
it "records the fields under a type" do
|
23
|
+
subject.types["Save"].keys.should =~ ["article", :namespace]
|
24
|
+
end
|
25
|
+
|
26
|
+
it "records multiple fields when there are more than one" do
|
27
|
+
subject.types["Article"].keys.should =~ ["Title", "Author", :namespace]
|
28
|
+
end
|
29
|
+
|
30
|
+
it "records the type of a field" do
|
31
|
+
subject.types["Save"]["article"][:type].should == "article:Article"
|
32
|
+
subject.namespaces["article"].should == "http://example.com/article"
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Wasabi::Parser do
|
4
|
+
context "with: no_namespace.xml" do
|
5
|
+
|
6
|
+
subject do
|
7
|
+
parser = Wasabi::Parser.new Nokogiri::XML(xml)
|
8
|
+
parser.parse
|
9
|
+
parser
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:xml) { fixture(:no_namespace) }
|
13
|
+
|
14
|
+
it "lists the types" do
|
15
|
+
subject.types.keys.sort.should == ["McContact", "McContactArray", "MpUser", "MpUserArray"]
|
16
|
+
end
|
17
|
+
|
18
|
+
it "ignores xsd:all" do
|
19
|
+
subject.types["MpUser"].keys.should == [:namespace]
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Wasabi::Parser do
|
4
|
+
context "with a WSDL defining xs:schema without targetNamespace" do
|
5
|
+
|
6
|
+
subject do
|
7
|
+
parser = Wasabi::Parser.new Nokogiri::XML(xml)
|
8
|
+
parser.parse
|
9
|
+
parser
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:xml) do
|
13
|
+
%Q{
|
14
|
+
<definitions xmlns='http://schemas.xmlsoap.org/wsdl/'
|
15
|
+
xmlns:xs='http://www.w3.org/2001/XMLSchema'
|
16
|
+
targetNamespace='http://def.example.com'>
|
17
|
+
<types>
|
18
|
+
<xs:schema elementFormDefault='qualified'>
|
19
|
+
<xs:element name='Save'>
|
20
|
+
<xs:complexType></xs:complexType>
|
21
|
+
</xs:element>
|
22
|
+
</xs:schema>
|
23
|
+
</types>
|
24
|
+
</definitions>
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
# Don't know if real WSDL files omit targetNamespace from xs:schema,
|
29
|
+
# but I suppose we should do something reasonable if they do.
|
30
|
+
|
31
|
+
it "defaults to the target namespace from xs:definitions" do
|
32
|
+
subject.types["Save"][:namespace].should == "http://def.example.com"
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wasabi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
|
-
-
|
7
|
+
- 2
|
8
8
|
- 0
|
9
9
|
- 0
|
10
|
-
version:
|
10
|
+
version: 2.0.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Daniel Harrington
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-07-
|
18
|
+
date: 2011-07-07 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: nokogiri
|
@@ -114,25 +114,34 @@ files:
|
|
114
114
|
- README.md
|
115
115
|
- Rakefile
|
116
116
|
- lib/wasabi.rb
|
117
|
+
- lib/wasabi/core_ext/object.rb
|
117
118
|
- lib/wasabi/core_ext/string.rb
|
118
119
|
- lib/wasabi/document.rb
|
119
120
|
- lib/wasabi/parser.rb
|
120
121
|
- lib/wasabi/version.rb
|
121
122
|
- spec/fixtures/authentication.xml
|
122
123
|
- spec/fixtures/geotrust.xml
|
124
|
+
- spec/fixtures/lower_camel.xml
|
125
|
+
- spec/fixtures/multiple_namespaces.xml
|
126
|
+
- spec/fixtures/multiple_types.xml
|
123
127
|
- spec/fixtures/namespaced_actions.xml
|
124
128
|
- spec/fixtures/no_namespace.xml
|
125
129
|
- spec/fixtures/soap12.xml
|
126
130
|
- spec/fixtures/two_bindings.xml
|
127
131
|
- spec/spec_helper.rb
|
128
132
|
- spec/support/fixture.rb
|
133
|
+
- spec/wasabi/core_ext/object_spec.rb
|
129
134
|
- spec/wasabi/core_ext/string_spec.rb
|
130
135
|
- spec/wasabi/document/authentication_spec.rb
|
131
136
|
- spec/wasabi/document/geotrust_spec.rb
|
137
|
+
- spec/wasabi/document/multiple_namespaces_spec.rb
|
132
138
|
- spec/wasabi/document/namespaced_actions_spec.rb
|
133
139
|
- spec/wasabi/document/no_namespace_spec.rb
|
134
140
|
- spec/wasabi/document/soap12_spec.rb
|
135
141
|
- spec/wasabi/document/two_bindings_spec.rb
|
142
|
+
- spec/wasabi/parser/multiple_namespaces_spec.rb
|
143
|
+
- spec/wasabi/parser/no_namespace_spec.rb
|
144
|
+
- spec/wasabi/parser/no_target_namespace_spec.rb
|
136
145
|
- spec/wasabi/wasabi_spec.rb
|
137
146
|
- wasabi.gemspec
|
138
147
|
homepage: https://github.com/rubiii/wasabi
|
@@ -171,17 +180,25 @@ summary: A simple WSDL parser
|
|
171
180
|
test_files:
|
172
181
|
- spec/fixtures/authentication.xml
|
173
182
|
- spec/fixtures/geotrust.xml
|
183
|
+
- spec/fixtures/lower_camel.xml
|
184
|
+
- spec/fixtures/multiple_namespaces.xml
|
185
|
+
- spec/fixtures/multiple_types.xml
|
174
186
|
- spec/fixtures/namespaced_actions.xml
|
175
187
|
- spec/fixtures/no_namespace.xml
|
176
188
|
- spec/fixtures/soap12.xml
|
177
189
|
- spec/fixtures/two_bindings.xml
|
178
190
|
- spec/spec_helper.rb
|
179
191
|
- spec/support/fixture.rb
|
192
|
+
- spec/wasabi/core_ext/object_spec.rb
|
180
193
|
- spec/wasabi/core_ext/string_spec.rb
|
181
194
|
- spec/wasabi/document/authentication_spec.rb
|
182
195
|
- spec/wasabi/document/geotrust_spec.rb
|
196
|
+
- spec/wasabi/document/multiple_namespaces_spec.rb
|
183
197
|
- spec/wasabi/document/namespaced_actions_spec.rb
|
184
198
|
- spec/wasabi/document/no_namespace_spec.rb
|
185
199
|
- spec/wasabi/document/soap12_spec.rb
|
186
200
|
- spec/wasabi/document/two_bindings_spec.rb
|
201
|
+
- spec/wasabi/parser/multiple_namespaces_spec.rb
|
202
|
+
- spec/wasabi/parser/no_namespace_spec.rb
|
203
|
+
- spec/wasabi/parser/no_target_namespace_spec.rb
|
187
204
|
- spec/wasabi/wasabi_spec.rb
|