wsdl-reader 0.0.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/.gitignore +4 -0
- data/.idea/.name +1 -0
- data/.idea/.rakeTasks +7 -0
- data/.idea/encodings.xml +5 -0
- data/.idea/misc.xml +350 -0
- data/.idea/modules.xml +9 -0
- data/.idea/projectCodeStyle.xml +123 -0
- data/.idea/vcs.xml +7 -0
- data/.idea/workspace.xml +683 -0
- data/.idea/wsdl-reader.iml +25 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/Guardfile +9 -0
- data/Rakefile +1 -0
- data/lib/wsdl-reader.rb +15 -0
- data/lib/wsdl-reader/binding.rb +148 -0
- data/lib/wsdl-reader/core_ext.rb +28 -0
- data/lib/wsdl-reader/error.rb +29 -0
- data/lib/wsdl-reader/message.rb +50 -0
- data/lib/wsdl-reader/parser.rb +105 -0
- data/lib/wsdl-reader/port_type.rb +106 -0
- data/lib/wsdl-reader/request.rb +213 -0
- data/lib/wsdl-reader/response.rb +72 -0
- data/lib/wsdl-reader/service.rb +56 -0
- data/lib/wsdl-reader/version.rb +5 -0
- data/lib/wsdl-reader/wsdl.rb +48 -0
- data/lib/wsdl-reader/xsd.rb +98 -0
- data/lib/wsdl-reader/xsd/complextype.rb +136 -0
- data/lib/wsdl-reader/xsd/convert.rb +142 -0
- data/lib/wsdl-reader/xsd/element.rb +168 -0
- data/lib/wsdl-reader/xsd/enumeration.rb +6 -0
- data/lib/wsdl-reader/xsd/restriction.rb +76 -0
- data/lib/wsdl-reader/xsd/sequence.rb +117 -0
- data/lib/wsdl-reader/xsd/simpletype.rb +83 -0
- data/spec/binding_spec.rb +67 -0
- data/spec/fixtures/OneFileUserService.wsdl +114 -0
- data/spec/fixtures/UserService.wsdl +63 -0
- data/spec/fixtures/UserService.xsd +56 -0
- data/spec/message_spec.rb +22 -0
- data/spec/parser_spec.rb +56 -0
- data/spec/port_type_spec.rb +32 -0
- data/spec/request_spec.rb +9 -0
- data/spec/spec_helper.rb +24 -0
- data/wsdl-reader.gemspec +27 -0
- metadata +122 -0
@@ -0,0 +1,76 @@
|
|
1
|
+
module SOAP
|
2
|
+
class XSD
|
3
|
+
class Restriction < Hash
|
4
|
+
def initialize( content )
|
5
|
+
content.attributes.each { |name, value|
|
6
|
+
self[name.to_sym] = value
|
7
|
+
}
|
8
|
+
content.find_all{ |e| e.class == REXML::Element }.each { |restrictions|
|
9
|
+
case restrictions.name
|
10
|
+
when "annotation"
|
11
|
+
###############################################################################
|
12
|
+
warn "xsd:annotation in xsd:restriction is not yet supported!"
|
13
|
+
###############################################################################
|
14
|
+
when "fractionDigits"
|
15
|
+
###############################################################################
|
16
|
+
warn "xsd:fractionDigits in xsd:restriction is not yet supported!"
|
17
|
+
###############################################################################
|
18
|
+
when "enumeration"
|
19
|
+
self[:enumeration] = SOAP::XSD::Enumeration.new unless self.has_key?( :enumeration )
|
20
|
+
self[:enumeration] << restrictions.attributes['value']
|
21
|
+
when "length"
|
22
|
+
###############################################################################
|
23
|
+
warn "xsd:length in xsd:restriction is not yet supported!"
|
24
|
+
###############################################################################
|
25
|
+
when "maxExclusive"
|
26
|
+
###############################################################################
|
27
|
+
warn "xsd:maxExclusive in xsd:restriction is not yet supported!"
|
28
|
+
###############################################################################
|
29
|
+
when "maxInclusive"
|
30
|
+
###############################################################################
|
31
|
+
warn "xsd:maxInclusive in xsd:restriction is not yet supported!"
|
32
|
+
###############################################################################
|
33
|
+
when "maxLength"
|
34
|
+
###############################################################################
|
35
|
+
warn "xsd:maxLength in xsd:restriction is not yet supported!"
|
36
|
+
###############################################################################
|
37
|
+
when "minExclusive"
|
38
|
+
###############################################################################
|
39
|
+
warn "xsd:minExclusive in xsd:restriction is not yet supported!"
|
40
|
+
###############################################################################
|
41
|
+
when "minInclusive"
|
42
|
+
###############################################################################
|
43
|
+
warn "xsd:minInclusive in xsd:restriction is not yet supported!"
|
44
|
+
###############################################################################
|
45
|
+
when "minLength"
|
46
|
+
###############################################################################
|
47
|
+
warn "xsd:minLength in xsd:restriction is not yet supported!"
|
48
|
+
###############################################################################
|
49
|
+
when "pattern"
|
50
|
+
###############################################################################
|
51
|
+
warn "xsd:pattern in xsd:restriction is not yet supported!"
|
52
|
+
###############################################################################
|
53
|
+
when "simpleType"
|
54
|
+
###############################################################################
|
55
|
+
warn "xsd:simpleType in xsd:restriction is not yet supported!"
|
56
|
+
###############################################################################
|
57
|
+
when "totalDigits"
|
58
|
+
###############################################################################
|
59
|
+
warn "xsd:totalDigits in xsd:restriction is not yet supported!"
|
60
|
+
###############################################################################
|
61
|
+
when "whiteSpace"
|
62
|
+
###############################################################################
|
63
|
+
warn "xsd:whiteSpace in xsd:restriction is not yet supported!"
|
64
|
+
###############################################################################
|
65
|
+
else
|
66
|
+
warn "Ignoring `#{restrictions.name}' in xsd:restriction for xsd:simpleType `#{type.attributes['name']}'"
|
67
|
+
end
|
68
|
+
}
|
69
|
+
end
|
70
|
+
|
71
|
+
def responseToHash( xml, types )
|
72
|
+
SOAP::XSD::Convert.to_ruby( self[:base].to_s, xml )
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
module SOAP
|
2
|
+
class XSD
|
3
|
+
class Sequence < Hash
|
4
|
+
def initialize( type )
|
5
|
+
type.attributes.each { |name, value|
|
6
|
+
self[name.to_sym] = value
|
7
|
+
}
|
8
|
+
|
9
|
+
type.find_all{ |e| e.class == REXML::Element }.each { |content|
|
10
|
+
case content.name
|
11
|
+
when "annotation"
|
12
|
+
###############################################################################
|
13
|
+
warn "xsd:annotation in xsd:sequence is not yet supported!"
|
14
|
+
###############################################################################
|
15
|
+
when "element"
|
16
|
+
raise SOAP::LCElementError, "Malformated sequence" unless self[:type].nil? or self[:type] = :element
|
17
|
+
if self[:type].nil?
|
18
|
+
self[:type] = :element
|
19
|
+
self[:element] = Array.new
|
20
|
+
end
|
21
|
+
self[:element] << SOAP::XSD::Element.new( content )
|
22
|
+
when "choice"
|
23
|
+
raise SOAP::LCElementError, "Malformated sequence" unless self[:type].nil? or self[:type] = :choice
|
24
|
+
self[:type] = :choice
|
25
|
+
###############################################################################
|
26
|
+
warn "xsd:choice in xsd:sequence is not yet supported!"
|
27
|
+
###############################################################################
|
28
|
+
when "group"
|
29
|
+
raise SOAP::LCElementError, "Malformated sequence" unless self[:type].nil? or self[:type] = :group
|
30
|
+
self[:type] = :group
|
31
|
+
###############################################################################
|
32
|
+
warn "xsd:group in xsd:sequence is not yet supported!"
|
33
|
+
###############################################################################
|
34
|
+
when "sequence"
|
35
|
+
raise SOAP::LCElementError, "Malformated sequence" unless self[:type].nil? or self[:type] = :sequence
|
36
|
+
self[:type] = :sequence
|
37
|
+
###############################################################################
|
38
|
+
warn "xsd:sequence in xsd:sequence is not yet supported!"
|
39
|
+
###############################################################################
|
40
|
+
when "any"
|
41
|
+
raise SOAP::LCElementError, "Malformated sequence" unless self[:type].nil? or self[:type] = :any
|
42
|
+
self[:type] = :any
|
43
|
+
###############################################################################
|
44
|
+
warn "xsd:any in xsd:sequence is not yet supported!"
|
45
|
+
###############################################################################
|
46
|
+
else
|
47
|
+
raise SOAP::LCElementError, "Invalid element `#{content.name}' in xsd:sequence"
|
48
|
+
end
|
49
|
+
}
|
50
|
+
end
|
51
|
+
|
52
|
+
def display( types, args )
|
53
|
+
r = ""
|
54
|
+
|
55
|
+
case self[:type]
|
56
|
+
when :element
|
57
|
+
self[:element].each { |element|
|
58
|
+
r << element.display( types, args )
|
59
|
+
}
|
60
|
+
when :choice
|
61
|
+
###############################################################################
|
62
|
+
warn "xsd:choice in xsd:sequence is not yet supported!"
|
63
|
+
###############################################################################
|
64
|
+
when :group
|
65
|
+
###############################################################################
|
66
|
+
warn "xsd:group in xsd:sequence is not yet supported!"
|
67
|
+
###############################################################################
|
68
|
+
when :sequence
|
69
|
+
###############################################################################
|
70
|
+
warn "xsd:sequence in xsd:sequence is not yet supported!"
|
71
|
+
###############################################################################
|
72
|
+
when :any
|
73
|
+
###############################################################################
|
74
|
+
warn "xsd:any in xsd:sequence is not yet supported!"
|
75
|
+
###############################################################################
|
76
|
+
else
|
77
|
+
raise SOAP::LCWSDLError, "Malformated sequence `#{self[:name]}'"
|
78
|
+
end
|
79
|
+
|
80
|
+
return r
|
81
|
+
end
|
82
|
+
|
83
|
+
def responseToHash( xml, types )
|
84
|
+
r = {}
|
85
|
+
|
86
|
+
case self[:type]
|
87
|
+
when :element
|
88
|
+
self[:element].each { |element|
|
89
|
+
element.responseToHash( xml, types ).each { |k, v|
|
90
|
+
r[k] = v
|
91
|
+
}
|
92
|
+
}
|
93
|
+
when :choice
|
94
|
+
###############################################################################
|
95
|
+
warn "xsd:choice in xsd:sequence is not yet supported!"
|
96
|
+
###############################################################################
|
97
|
+
when :group
|
98
|
+
###############################################################################
|
99
|
+
warn "xsd:group in xsd:sequence is not yet supported!"
|
100
|
+
###############################################################################
|
101
|
+
when :sequence
|
102
|
+
###############################################################################
|
103
|
+
warn "xsd:sequence in xsd:sequence is not yet supported!"
|
104
|
+
###############################################################################
|
105
|
+
when :any
|
106
|
+
###############################################################################
|
107
|
+
warn "xsd:any in xsd:sequence is not yet supported!"
|
108
|
+
###############################################################################
|
109
|
+
else
|
110
|
+
raise SOAP::LCWSDLError, "Malformated sequence `#{self[:name]}'"
|
111
|
+
end
|
112
|
+
|
113
|
+
return r
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
module SOAP
|
2
|
+
class XSD
|
3
|
+
class SimpleType < Hash
|
4
|
+
def initialize( type )
|
5
|
+
type.attributes.each { |name, value|
|
6
|
+
self[name.to_sym] = value
|
7
|
+
}
|
8
|
+
|
9
|
+
type.find_all{ |e| e.class == REXML::Element }.each { |content|
|
10
|
+
case content.name
|
11
|
+
when "list"
|
12
|
+
raise SOAP::LCElementError, "Malformated simpleType `#{type.attributes['name']}'" unless self[:type].nil?
|
13
|
+
self[:type] = :list
|
14
|
+
self[:list] = nil
|
15
|
+
###############################################################################
|
16
|
+
warn "xsd:list in xsd:simpleType is not yet supported!"
|
17
|
+
###############################################################################
|
18
|
+
when "union"
|
19
|
+
raise SOAP::LCElementError, "Malformated simpleType `#{type.attributes['name']}'" unless self[:type].nil?
|
20
|
+
self[:type] = :union
|
21
|
+
self[:union] = nil
|
22
|
+
###############################################################################
|
23
|
+
warn "xsd:union in xsd:simpleType is not yet supported!"
|
24
|
+
###############################################################################
|
25
|
+
when "restriction"
|
26
|
+
raise SOAP::LCElementError, "Malformated simpleType `#{type.attributes['name']}'" unless self[:type].nil?
|
27
|
+
self[:type] = :restriction
|
28
|
+
self[:restriction] = SOAP::XSD::Restriction.new( content )
|
29
|
+
when "annotation"
|
30
|
+
###############################################################################
|
31
|
+
warn "xsd:annotation in xsd:simpleType is not yet supported!"
|
32
|
+
###############################################################################
|
33
|
+
else
|
34
|
+
raise SOAP::LCElementError, "Invalid element `#{content.name}' in xsd:simpleType `#{type.attributes['name']}'"
|
35
|
+
end
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
def display( types, args )
|
40
|
+
r = ""
|
41
|
+
|
42
|
+
case self[:type]
|
43
|
+
when :restriction
|
44
|
+
# TODO ########################################################################
|
45
|
+
# TODO ########################################################################
|
46
|
+
# TODO ########################################################################
|
47
|
+
# TODO ########################################################################
|
48
|
+
when :list
|
49
|
+
###############################################################################
|
50
|
+
warn "xsd:list in xsd:simpleType is not yet supported!"
|
51
|
+
###############################################################################
|
52
|
+
when :union
|
53
|
+
###############################################################################
|
54
|
+
warn "xsd:union in xsd:simpleType is not yet supported!"
|
55
|
+
###############################################################################
|
56
|
+
else
|
57
|
+
raise SOAP::LCWSDLError, "Malformated simpleType `#{self[:name]}'"
|
58
|
+
end
|
59
|
+
|
60
|
+
return r
|
61
|
+
end
|
62
|
+
|
63
|
+
def responseToHash( xml, types )
|
64
|
+
r = nil
|
65
|
+
case self[:type]
|
66
|
+
when :restriction
|
67
|
+
r = self[:restriction].responseToHash( xml, types )
|
68
|
+
when :list
|
69
|
+
###############################################################################
|
70
|
+
warn "xsd:list in xsd:simpleType is not yet supported!"
|
71
|
+
###############################################################################
|
72
|
+
when :union
|
73
|
+
###############################################################################
|
74
|
+
warn "xsd:union in xsd:simpleType is not yet supported!"
|
75
|
+
###############################################################################
|
76
|
+
else
|
77
|
+
raise SOAP::LCWSDLError, "Malformated simpleType `#{self[:name]}'"
|
78
|
+
end
|
79
|
+
return r
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "WSDL Binding" do
|
4
|
+
|
5
|
+
context "WSDL::Reader::Bindings" do
|
6
|
+
subject { WSDL::Reader::Parser.new('spec/fixtures/UserService.wsdl').bindings }
|
7
|
+
|
8
|
+
it "child of Hash" do
|
9
|
+
subject.class.superclass.should be Hash
|
10
|
+
end
|
11
|
+
|
12
|
+
it "#get_operations with binding UserServicePortBinding" do
|
13
|
+
operations = subject.get_operations "UserServicePortBinding"
|
14
|
+
operations.should have(2).operation
|
15
|
+
operations.should eq %w{getFirstName getLastName}
|
16
|
+
end
|
17
|
+
|
18
|
+
it "#get_binding_for_operation_name with binding = UserServicePortBinding and operation = getFirstName" do
|
19
|
+
bindings_array = subject.get_binding_for_operation_name "UserServicePortBinding", "getFirstName"
|
20
|
+
|
21
|
+
bindings_array.should have(1).binding
|
22
|
+
bindings_array.first.should be_a WSDL::Reader::Binding
|
23
|
+
bindings_array.first.name.should eq "UserServicePortBinding"
|
24
|
+
bindings_array.first.operations.keys.should include "getFirstName"
|
25
|
+
end
|
26
|
+
|
27
|
+
it "#get_binding_for_operation_name operation = getFirstName but without binding" do
|
28
|
+
bindings_array = subject.get_binding_for_operation_name "getFirstName"
|
29
|
+
|
30
|
+
bindings_array.should have(1).binding
|
31
|
+
bindings_array.first.should be_a WSDL::Reader::Binding
|
32
|
+
bindings_array.first.name.should eq "UserServicePortBinding"
|
33
|
+
bindings_array.first.operations.keys.should include "getFirstName"
|
34
|
+
end
|
35
|
+
|
36
|
+
it "#all_operations should eql to #get_operations(nil)" do
|
37
|
+
subject.get_operations.should eql subject.all_operations
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context "WSDL::Reader::Binding" do
|
42
|
+
|
43
|
+
def operations
|
44
|
+
{ "getFirstName" => { :name => "getFirstName",
|
45
|
+
:soapAction => "",
|
46
|
+
:input => { :body => { :use => "literal" } },
|
47
|
+
:output => { :body => { :use => "literal" } } },
|
48
|
+
|
49
|
+
"getLastName" => { :name => "getLastName",
|
50
|
+
:soapAction => "",
|
51
|
+
:input => { :body => { :use => "literal" } },
|
52
|
+
:output => { :body => { :use => "literal" } } }
|
53
|
+
}
|
54
|
+
end
|
55
|
+
|
56
|
+
subject do
|
57
|
+
WSDL::Reader::Parser.new('spec/fixtures/UserService.wsdl').bindings.values.first
|
58
|
+
end
|
59
|
+
|
60
|
+
its(:operations) { should eq operations }
|
61
|
+
its(:name) { should eq "UserServicePortBinding" }
|
62
|
+
its(:type) { should eq "tns:UserService" }
|
63
|
+
its(:style) { should eq "document" }
|
64
|
+
its(:transport) { should eq "http://schemas.xmlsoap.org/soap/http" }
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
@@ -0,0 +1,114 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
|
3
|
+
xmlns:tns="http://example.com/UserService/"
|
4
|
+
xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
5
|
+
name="UserService" targetNamespace="http://example.com/UserService/">
|
6
|
+
<types>
|
7
|
+
<xs:schema xmlns:tns="http://example.com/UserService/type/" xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
8
|
+
targetNamespace="http://example.com/UserService/type/" version="1.0">
|
9
|
+
|
10
|
+
<xs:element name="getFirstName" type="tns:GetFirstName"/>
|
11
|
+
<xs:element name="getLastName" type="tns:GetLastName"/>
|
12
|
+
|
13
|
+
<xs:complexType name="GetFirstName">
|
14
|
+
<xs:annotation>
|
15
|
+
<xs:documentation>Foo Bar</xs:documentation>
|
16
|
+
</xs:annotation>
|
17
|
+
<xs:sequence>
|
18
|
+
<xs:element name="userIdentifier" type="xs:string" minOccurs="0"/>
|
19
|
+
<xs:element name="filter" minOccurs="0">
|
20
|
+
<xs:complexType>
|
21
|
+
<xs:sequence>
|
22
|
+
<xs:element ref="tns:age"/>
|
23
|
+
<xs:element ref="tns:gender"/>
|
24
|
+
</xs:sequence>
|
25
|
+
</xs:complexType>
|
26
|
+
</xs:element>
|
27
|
+
</xs:sequence>
|
28
|
+
<xs:attribute name="id" type="xs:string"/>
|
29
|
+
</xs:complexType>
|
30
|
+
|
31
|
+
<xs:complexType name="GetLastName">
|
32
|
+
<xs:annotation>
|
33
|
+
<xs:documentation>Foo Bar</xs:documentation>
|
34
|
+
</xs:annotation>
|
35
|
+
<xs:complexContent>
|
36
|
+
<xs:restriction base="tns:GetFirstName">
|
37
|
+
<xs:sequence>
|
38
|
+
<xs:element name="userIdentifier" type="xs:string" minOccurs="0"/>
|
39
|
+
</xs:sequence>
|
40
|
+
</xs:restriction>
|
41
|
+
</xs:complexContent>
|
42
|
+
</xs:complexType>
|
43
|
+
|
44
|
+
<xs:element name="gender">
|
45
|
+
<xs:simpleType>
|
46
|
+
<xs:restriction base="xs:string">
|
47
|
+
<xs:enumeration value="male"/>
|
48
|
+
<xs:enumeration value="female"/>
|
49
|
+
</xs:restriction>
|
50
|
+
</xs:simpleType>
|
51
|
+
</xs:element>
|
52
|
+
|
53
|
+
<xs:element name="age">
|
54
|
+
<xs:simpleType>
|
55
|
+
<xs:restriction base="xs:integer">
|
56
|
+
<xs:minInclusive value="0"/>
|
57
|
+
<xs:maxInclusive value="100"/>
|
58
|
+
</xs:restriction>
|
59
|
+
</xs:simpleType>
|
60
|
+
</xs:element>
|
61
|
+
</xs:schema>
|
62
|
+
</types>
|
63
|
+
|
64
|
+
<message name="getFirstName">
|
65
|
+
<part name="parameters" element="tns:GetFirstName"/>
|
66
|
+
</message>
|
67
|
+
<message name="getLastName">
|
68
|
+
<part name="parameters" element="tns:GetLastName"/>
|
69
|
+
</message>
|
70
|
+
|
71
|
+
<message name="UserNameResponse">
|
72
|
+
<part name="parameters" element="xs:string"/>
|
73
|
+
</message>
|
74
|
+
|
75
|
+
<portType name="UserService">
|
76
|
+
<operation name="getFirstName">
|
77
|
+
<input message="tns:getFirstName"/>
|
78
|
+
<output message="tns:UserNameResponse"/>
|
79
|
+
</operation>
|
80
|
+
<operation name="getLastName">
|
81
|
+
<input message="tns:getLastName"/>
|
82
|
+
<output message="tns:UserNameResponse"/>
|
83
|
+
</operation>
|
84
|
+
</portType>
|
85
|
+
|
86
|
+
<binding name="UserServicePortBinding" type="tns:UserService">
|
87
|
+
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
|
88
|
+
<operation name="getFirstName">
|
89
|
+
<soap:operation soapAction=""/>
|
90
|
+
<input>
|
91
|
+
<soap:body use="literal"/>
|
92
|
+
</input>
|
93
|
+
<output>
|
94
|
+
<soap:body use="literal"/>
|
95
|
+
</output>
|
96
|
+
</operation>
|
97
|
+
<operation name="getLastName">
|
98
|
+
<soap:operation soapAction=""/>
|
99
|
+
<input>
|
100
|
+
<soap:body use="literal"/>
|
101
|
+
</input>
|
102
|
+
<output>
|
103
|
+
<soap:body use="literal"/>
|
104
|
+
</output>
|
105
|
+
</operation>
|
106
|
+
</binding>
|
107
|
+
|
108
|
+
<service name="UserService">
|
109
|
+
<port name="UserServicePort" binding="tns:UserServicePortBinding">
|
110
|
+
<soap:address location="REPLACE_WITH_ACTUAL_URL"/>
|
111
|
+
</port>
|
112
|
+
</service>
|
113
|
+
|
114
|
+
</definitions>
|