wsdl-reader 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- 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,136 @@
|
|
1
|
+
module SOAP
|
2
|
+
class XSD
|
3
|
+
class ComplexType < 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 "simpleContent"
|
12
|
+
raise SOAP::LCElementError, "Malformated complexType `#{type.attributes['name']}'" unless self[:type].nil?
|
13
|
+
self[:type] = :simpleContent
|
14
|
+
###############################################################################
|
15
|
+
warn "xsd:simpleContent in xsd:complexType (global definition) is not yet supported!"
|
16
|
+
###############################################################################
|
17
|
+
when "complexContent"
|
18
|
+
raise SOAP::LCElementError, "Malformated complexType `#{type.attributes['name']}'" unless self[:type].nil?
|
19
|
+
self[:type] = :complexContent
|
20
|
+
###############################################################################
|
21
|
+
warn "xsd:complexContent in xsd:complexType (global definition) is not yet supported!"
|
22
|
+
###############################################################################
|
23
|
+
when "group"
|
24
|
+
raise SOAP::LCElementError, "Malformated complexType `#{type.attributes['name']}'" unless self[:type].nil?
|
25
|
+
self[:type] = :group
|
26
|
+
###############################################################################
|
27
|
+
warn "xsd:group in xsd:complexType (global definition) is not yet supported!"
|
28
|
+
###############################################################################
|
29
|
+
when "all"
|
30
|
+
raise SOAP::LCElementError, "Malformated complexType `#{type.attributes['name']}'" unless self[:type].nil?
|
31
|
+
self[:type] = :all
|
32
|
+
###############################################################################
|
33
|
+
warn "xsd:all in xsd:complexType (global definition) is not yet supported!"
|
34
|
+
###############################################################################
|
35
|
+
when "choise"
|
36
|
+
raise SOAP::LCElementError, "Malformated complexType `#{type.attributes['name']}'" unless self[:type].nil?
|
37
|
+
self[:type] = :choise
|
38
|
+
###############################################################################
|
39
|
+
warn "xsd:choise in xsd:complexType (global definition) is not yet supported!"
|
40
|
+
###############################################################################
|
41
|
+
when "sequence"
|
42
|
+
raise SOAP::LCElementError, "Malformated complexType `#{type.attributes['name']}'" unless self[:type].nil?
|
43
|
+
self[:type] = :sequence
|
44
|
+
self[:sequence] = SOAP::XSD::Sequence.new( content )
|
45
|
+
when "attribute"
|
46
|
+
raise SOAP::LCElementError, "Malformated complexType `#{type.attributes['name']}'" if (not(self[:attributes_type].nil?) and self[:attributes_type] != :attribute) or [:simpleContent, :complexContent].include?(self[:type])
|
47
|
+
self[:attributes_type] = :attribute
|
48
|
+
###############################################################################
|
49
|
+
warn "xsd:attribute in xsd:complexType (global definition) is not yet supported!"
|
50
|
+
###############################################################################
|
51
|
+
when "attributeGroup"
|
52
|
+
raise SOAP::LCElementError, "Malformated complexType `#{type.attributes['name']}'" if (not(self[:attributes_type].nil?) and self[:attributes_type] != :attributeGroup) or [:simpleContent, :complexContent].include?(self[:type])
|
53
|
+
self[:attributes_type] = :attributeGroup
|
54
|
+
###############################################################################
|
55
|
+
warn "xsd:attributeGroup in xsd:complexType (global definition) is not yet supported!"
|
56
|
+
###############################################################################
|
57
|
+
when "anyAttribute"
|
58
|
+
raise SOAP::LCElementError, "Malformated complexType `#{type.attributes['name']}'" if not(self[:any_attributes].nil?) or [:simpleContent, :complexContent].include?(self[:type])
|
59
|
+
self[:any_attributes] = :anyAttribute
|
60
|
+
###############################################################################
|
61
|
+
warn "xsd:anyAttribute in xsd:complexType (global definition) is not yet supported!"
|
62
|
+
###############################################################################
|
63
|
+
when "annotation"
|
64
|
+
###############################################################################
|
65
|
+
warn "xsd:annotation in xsd:complexType (global definition) (global definition) is not yet supported!"
|
66
|
+
###############################################################################
|
67
|
+
else
|
68
|
+
raise SOAP::LCElementError, "Invalid element `#{content.name}' in xsd:complexType `#{type.attributes['name']}'"
|
69
|
+
end
|
70
|
+
}
|
71
|
+
end
|
72
|
+
|
73
|
+
def display( types, args )
|
74
|
+
r = ""
|
75
|
+
|
76
|
+
case self[:type]
|
77
|
+
when :simpleContent
|
78
|
+
###############################################################################
|
79
|
+
warn "xsd:simpleContent in xsd:complexType (global definition) is not yet supported!"
|
80
|
+
###############################################################################
|
81
|
+
when :complexContent
|
82
|
+
###############################################################################
|
83
|
+
warn "xsd:complexContent in xsd:complexType (global definition) is not yet supported!"
|
84
|
+
###############################################################################
|
85
|
+
when :group
|
86
|
+
###############################################################################
|
87
|
+
warn "xsd:group in xsd:complexType (global definition) is not yet supported!"
|
88
|
+
###############################################################################
|
89
|
+
when :all
|
90
|
+
###############################################################################
|
91
|
+
warn "xsd:all in xsd:complexType (global definition) is not yet supported!"
|
92
|
+
###############################################################################
|
93
|
+
when :choise
|
94
|
+
###############################################################################
|
95
|
+
warn "xsd:choise in xsd:complexType (global definition) is not yet supported!"
|
96
|
+
###############################################################################
|
97
|
+
when :sequence
|
98
|
+
r << self[:sequence].display( types, args )
|
99
|
+
#else
|
100
|
+
# raise SOAP::LCWSDLError, "Malformated complexType `#{self[:name]}'"
|
101
|
+
end
|
102
|
+
|
103
|
+
return r
|
104
|
+
end
|
105
|
+
|
106
|
+
def responseToHash( xml, types )
|
107
|
+
r = {}
|
108
|
+
case self[:type]
|
109
|
+
when :simpleContent
|
110
|
+
###############################################################################
|
111
|
+
warn "xsd:simpleContent in xsd:complexType (global definition) is not yet supported!"
|
112
|
+
###############################################################################
|
113
|
+
when :complexContent
|
114
|
+
###############################################################################
|
115
|
+
warn "xsd:complexContent in xsd:complexType (global definition) is not yet supported!"
|
116
|
+
###############################################################################
|
117
|
+
when :group
|
118
|
+
###############################################################################
|
119
|
+
warn "xsd:group in xsd:complexType (global definition) is not yet supported!"
|
120
|
+
###############################################################################
|
121
|
+
when :all
|
122
|
+
###############################################################################
|
123
|
+
warn "xsd:all in xsd:complexType (global definition) is not yet supported!"
|
124
|
+
###############################################################################
|
125
|
+
when :choise
|
126
|
+
###############################################################################
|
127
|
+
warn "xsd:choise in xsd:complexType (global definition) is not yet supported!"
|
128
|
+
###############################################################################
|
129
|
+
when :sequence
|
130
|
+
r = self[:sequence].responseToHash( xml, types )
|
131
|
+
end
|
132
|
+
return r
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
@@ -0,0 +1,142 @@
|
|
1
|
+
module SOAP
|
2
|
+
class XSD
|
3
|
+
class Convert
|
4
|
+
|
5
|
+
def self.to_ruby( t, v )
|
6
|
+
new().c( t.gsub( /.*:/, "xsd_" ), v )
|
7
|
+
end
|
8
|
+
|
9
|
+
def c( t, v )
|
10
|
+
self.method( t ).call( v )
|
11
|
+
end
|
12
|
+
|
13
|
+
def xsd_int( x )
|
14
|
+
x.to_i
|
15
|
+
end
|
16
|
+
alias_method :xsd_long, :xsd_int
|
17
|
+
alias_method :xsd_integer, :xsd_int
|
18
|
+
|
19
|
+
def xsd_float( x )
|
20
|
+
x.to_f
|
21
|
+
end
|
22
|
+
alias_method :xsd_double, :xsd_float
|
23
|
+
alias_method :xsd_decimal, :xsd_float
|
24
|
+
|
25
|
+
def xsd_string( x )
|
26
|
+
x
|
27
|
+
end
|
28
|
+
alias_method :xsd_normalizedString, :xsd_string
|
29
|
+
|
30
|
+
def xsd_boolean( x )
|
31
|
+
(x == "true")
|
32
|
+
end
|
33
|
+
|
34
|
+
def xsd_duration( x )
|
35
|
+
x
|
36
|
+
end
|
37
|
+
def xsd_dateTime( x )
|
38
|
+
x
|
39
|
+
end
|
40
|
+
def xsd_time( x )
|
41
|
+
x
|
42
|
+
end
|
43
|
+
def xsd_date( x )
|
44
|
+
x
|
45
|
+
end
|
46
|
+
def xsd_gYearMonth( x )
|
47
|
+
x
|
48
|
+
end
|
49
|
+
def xsd_gYear( x )
|
50
|
+
x
|
51
|
+
end
|
52
|
+
def xsd_gMonthDay( x )
|
53
|
+
x
|
54
|
+
end
|
55
|
+
def xsd_gDay( x )
|
56
|
+
x
|
57
|
+
end
|
58
|
+
def xsd_gMonth( x )
|
59
|
+
x
|
60
|
+
end
|
61
|
+
def xsd_base64Binary( x )
|
62
|
+
x
|
63
|
+
end
|
64
|
+
def xsd_hexBinary( x )
|
65
|
+
x
|
66
|
+
end
|
67
|
+
def xsd_anyURI( x )
|
68
|
+
x
|
69
|
+
end
|
70
|
+
def xsd_QName( x )
|
71
|
+
x
|
72
|
+
end
|
73
|
+
def xsd_NOTATION( x )
|
74
|
+
x
|
75
|
+
end
|
76
|
+
def xsd_token( x )
|
77
|
+
x
|
78
|
+
end
|
79
|
+
def xsd_language( x )
|
80
|
+
x
|
81
|
+
end
|
82
|
+
def xsd_Name( x )
|
83
|
+
x
|
84
|
+
end
|
85
|
+
def xsd_NMTOKEN( x )
|
86
|
+
x
|
87
|
+
end
|
88
|
+
def xsd_NCName( x )
|
89
|
+
x
|
90
|
+
end
|
91
|
+
def xsd_NMTOKENS( x )
|
92
|
+
x
|
93
|
+
end
|
94
|
+
def xsd_ID( x )
|
95
|
+
x
|
96
|
+
end
|
97
|
+
def xsd_IDREF( x )
|
98
|
+
x
|
99
|
+
end
|
100
|
+
def xsd_ENTITY( x )
|
101
|
+
x
|
102
|
+
end
|
103
|
+
def xsd_IDREFS( x )
|
104
|
+
x
|
105
|
+
end
|
106
|
+
def xsd_ENTITIES( x )
|
107
|
+
x
|
108
|
+
end
|
109
|
+
def xsd_nonPositiveInteger( x )
|
110
|
+
x
|
111
|
+
end
|
112
|
+
def xsd_nonNegativeInteger( x )
|
113
|
+
x
|
114
|
+
end
|
115
|
+
def xsd_negativeInteger( x )
|
116
|
+
x
|
117
|
+
end
|
118
|
+
def xsd_unsignedLong( x )
|
119
|
+
x
|
120
|
+
end
|
121
|
+
def xsd_positiveInteger( x )
|
122
|
+
x
|
123
|
+
end
|
124
|
+
def xsd_short( x )
|
125
|
+
x
|
126
|
+
end
|
127
|
+
def xsd_unsignedInt( x )
|
128
|
+
x
|
129
|
+
end
|
130
|
+
def xsd_byte( x )
|
131
|
+
x
|
132
|
+
end
|
133
|
+
def xsd_unsignedShort( x )
|
134
|
+
x
|
135
|
+
end
|
136
|
+
def xsd_unsignedByte( x )
|
137
|
+
x
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
@@ -0,0 +1,168 @@
|
|
1
|
+
module SOAP
|
2
|
+
class XSD
|
3
|
+
class Element < 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 "simpleType"
|
12
|
+
raise SOAP::LCElementError, "Malformated element `#{type.attributes['name']}'" unless self[:type].nil?
|
13
|
+
self[:type] = :simpleType
|
14
|
+
###############################################################################
|
15
|
+
warn "xsd:simpleType in xsd:element is not yet supported!"
|
16
|
+
###############################################################################
|
17
|
+
when "complexType"
|
18
|
+
raise SOAP::LCElementError, "Malformated element `#{type.attributes['name']}'" unless self[:type].nil?
|
19
|
+
self[:type] = :complexType
|
20
|
+
self[:complexType] = SOAP::XSD::ComplexType.new( content )
|
21
|
+
when "unique"
|
22
|
+
raise SOAP::LCElementError, "Malformated element `#{type.attributes['name']}'" unless self[:key].nil?
|
23
|
+
self[:key] = :unique
|
24
|
+
###############################################################################
|
25
|
+
warn "xsd:unique in xsd:element is not yet supported!"
|
26
|
+
###############################################################################
|
27
|
+
when "key"
|
28
|
+
raise SOAP::LCElementError, "Malformated element `#{type.attributes['name']}'" unless self[:key].nil?
|
29
|
+
self[:key] = :key
|
30
|
+
###############################################################################
|
31
|
+
warn "xsd:unique in xsd:element is not yet supported!"
|
32
|
+
###############################################################################
|
33
|
+
when "keyref"
|
34
|
+
raise SOAP::LCElementError, "Malformated element `#{type.attributes['name']}'" unless self[:key].nil?
|
35
|
+
self[:key] = :keyref
|
36
|
+
###############################################################################
|
37
|
+
warn "xsd:unique in xsd:element is not yet supported!"
|
38
|
+
###############################################################################
|
39
|
+
when "annotation"
|
40
|
+
###############################################################################
|
41
|
+
warn "xsd:annotation in xsd:complexType (global definition) (global definition) is not yet supported!"
|
42
|
+
###############################################################################
|
43
|
+
else
|
44
|
+
raise SOAP::LCElementError, "Invalid element `#{content.name}' in xsd:element `#{type.attributes['name']}'"
|
45
|
+
end
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
def display( types, args )
|
50
|
+
r = ""
|
51
|
+
|
52
|
+
min, max = getOccures( args )
|
53
|
+
|
54
|
+
if self[:type].is_a?(String) && SOAP::XSD::ANY_SIMPLE_TYPE.include?( self[:type].nns )
|
55
|
+
r << SOAP::XSD.displayBuiltinType( self[:name], args, min, max )
|
56
|
+
else
|
57
|
+
case types[self[:type].nns][:type]
|
58
|
+
when :simpleType
|
59
|
+
if args.keys.include?( self[:name].to_sym )
|
60
|
+
args[self[:name].to_sym] = [args[self[:name].to_sym]] unless args[self[:name].to_sym].class == Array
|
61
|
+
if args[self[:name].to_sym].size < min or args[self[:name].to_sym].size > max
|
62
|
+
raise SOAP::LCArgumentError, "Wrong number or values for parameter `#{name}'"
|
63
|
+
end
|
64
|
+
args[self[:name].to_sym].each { |v|
|
65
|
+
r << "<#{self[:name]}>"
|
66
|
+
r << "#{v}" ############ CHECK !!!
|
67
|
+
r << "</#{self[:name]}>\n"
|
68
|
+
}
|
69
|
+
elsif min > 0
|
70
|
+
raise SOAP::LCArgumentError, "Missing parameter `#{name}'" if min > 0
|
71
|
+
end
|
72
|
+
when :complexType
|
73
|
+
if args.keys.include?( self[:name].to_sym )
|
74
|
+
if args.keys.include?( self[:name].to_sym )
|
75
|
+
args[self[:name].to_sym] = [args[self[:name].to_sym]] unless args[self[:name].to_sym].class == Array
|
76
|
+
if args[self[:name].to_sym].size < min or args[self[:name].to_sym].size > max
|
77
|
+
raise SOAP::LCArgumentError, "Wrong number or values for parameter `#{name}'"
|
78
|
+
end
|
79
|
+
args[self[:name].to_sym].each { |v|
|
80
|
+
r << "<#{self[:name]}>"
|
81
|
+
r << types[self[:type].nns][:value].display( types, v )
|
82
|
+
r << "</#{self[:name]}>\n"
|
83
|
+
}
|
84
|
+
elsif min > 0
|
85
|
+
raise SOAP::LCArgumentError, "Missing parameter `#{name}'" if min > 0
|
86
|
+
end
|
87
|
+
else
|
88
|
+
r << "<#{self[:name]}>\n"
|
89
|
+
r << types[self[:type].nns][:value].display( types, args )
|
90
|
+
r << "</#{self[:name]}>\n"
|
91
|
+
end
|
92
|
+
else
|
93
|
+
raise SOAL::LCWSDLError, "Malformated element `#{self[:name]}'"
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
return r
|
98
|
+
end
|
99
|
+
|
100
|
+
def getOccures( args )
|
101
|
+
element_min = self[:minOccurs].to_i || 1
|
102
|
+
element_max = self[:maxOccurs] || "1"
|
103
|
+
if element_max == "unbounded"
|
104
|
+
if args.keys.include?(self[:name].to_sym)
|
105
|
+
if args[self[:name].to_sym].class == Array
|
106
|
+
element_max = args[self[:name].to_sym].size
|
107
|
+
else
|
108
|
+
element_max = 1
|
109
|
+
end
|
110
|
+
else
|
111
|
+
element_max = 1
|
112
|
+
end
|
113
|
+
else
|
114
|
+
element_max = element_max.to_i
|
115
|
+
end
|
116
|
+
|
117
|
+
return( [element_min, element_max] )
|
118
|
+
end
|
119
|
+
|
120
|
+
def responseToHash( xml, types )
|
121
|
+
r = {}
|
122
|
+
|
123
|
+
if SOAP::XSD::ANY_SIMPLE_TYPE.include?( self[:type].to_s.nns )
|
124
|
+
xml.each { |e|
|
125
|
+
if e.name == self[:name]
|
126
|
+
r[self[:name]] = SOAP::XSD::Convert.to_ruby( self[:type].to_s, e.text )
|
127
|
+
end
|
128
|
+
}
|
129
|
+
else
|
130
|
+
case self[:type]
|
131
|
+
when :simpleType
|
132
|
+
# **************************** TODO ************************************
|
133
|
+
when :complexType
|
134
|
+
# **************************** NEED TO BE VERIFIED ************************************
|
135
|
+
r = self[:complexType].responseToHash( xml, types )
|
136
|
+
else
|
137
|
+
xml.each { |e|
|
138
|
+
if e.name == self[:name]
|
139
|
+
case types[self[:type].to_s.nns][:type]
|
140
|
+
when :simpleType
|
141
|
+
if r.keys.include?(self[:name])
|
142
|
+
unless r[self[:name]].class == Array
|
143
|
+
r[self[:name]] = [r[self[:name]]]
|
144
|
+
end
|
145
|
+
r[self[:name]] << types[self[:type].to_s.nns][:value].responseToHash( e.text, types )
|
146
|
+
else
|
147
|
+
r[self[:name]] = types[self[:type].to_s.nns][:value].responseToHash( e.text, types )
|
148
|
+
end
|
149
|
+
else
|
150
|
+
if r.keys.include?(self[:name])
|
151
|
+
unless r[self[:name]].class == Array
|
152
|
+
r[self[:name]] = [r[self[:name]]]
|
153
|
+
end
|
154
|
+
r[self[:name]] << types[self[:type].to_s.nns][:value].responseToHash( e, types )
|
155
|
+
else
|
156
|
+
r[self[:name]] = types[self[:type].to_s.nns][:value].responseToHash( e, types )
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
}
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
return r
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|