soap4r 1.5.7 → 1.5.8
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/bin/wsdl2ruby.rb +8 -2
- data/lib/soap/baseData.rb +93 -43
- data/lib/soap/element.rb +11 -8
- data/lib/soap/encodingstyle/handler.rb +15 -4
- data/lib/soap/encodingstyle/literalHandler.rb +18 -24
- data/lib/soap/encodingstyle/soapHandler.rb +34 -77
- data/lib/soap/generator.rb +74 -48
- data/lib/soap/header/handler.rb +1 -1
- data/lib/soap/header/mappinghandler.rb +47 -0
- data/lib/soap/mapping/encodedregistry.rb +19 -13
- data/lib/soap/mapping/factory.rb +19 -3
- data/lib/soap/mapping/literalregistry.rb +47 -35
- data/lib/soap/mapping/mapping.rb +92 -24
- data/lib/soap/mapping/registry.rb +34 -18
- data/lib/soap/mapping/schemadefinition.rb +8 -1
- data/lib/soap/mapping/typeMap.rb +18 -0
- data/lib/soap/mapping/wsdlencodedregistry.rb +8 -50
- data/lib/soap/mapping/wsdlliteralregistry.rb +45 -39
- data/lib/soap/nestedexception.rb +42 -0
- data/lib/soap/netHttpClient.rb +1 -0
- data/lib/soap/ns.rb +34 -0
- data/lib/soap/parser.rb +32 -29
- data/lib/soap/processor.rb +1 -1
- data/lib/soap/rpc/driver.rb +1 -0
- data/lib/soap/rpc/element.rb +18 -6
- data/lib/soap/rpc/httpserver.rb +38 -24
- data/lib/soap/rpc/proxy.rb +14 -11
- data/lib/soap/rpc/router.rb +4 -1
- data/lib/soap/soap.rb +7 -6
- data/lib/soap/wsdlDriver.rb +29 -8
- data/lib/tags +5690 -0
- data/lib/wsdl/definitions.rb +26 -40
- data/lib/wsdl/info.rb +11 -0
- data/lib/wsdl/parser.rb +2 -2
- data/lib/wsdl/soap/cgiStubCreator.rb +10 -5
- data/lib/wsdl/soap/classDefCreator.rb +140 -113
- data/lib/wsdl/soap/classDefCreatorSupport.rb +94 -12
- data/lib/wsdl/soap/classNameCreator.rb +54 -0
- data/lib/wsdl/soap/clientSkeltonCreator.rb +6 -5
- data/lib/wsdl/soap/complexType.rb +10 -1
- data/lib/wsdl/soap/definitions.rb +4 -0
- data/lib/wsdl/soap/driverCreator.rb +14 -6
- data/lib/wsdl/soap/element.rb +4 -0
- data/lib/wsdl/soap/encodedMappingRegistryCreator.rb +11 -55
- data/lib/wsdl/soap/literalMappingRegistryCreator.rb +28 -126
- data/lib/wsdl/soap/mappingRegistryCreator.rb +9 -3
- data/lib/wsdl/soap/mappingRegistryCreatorSupport.rb +209 -94
- data/lib/wsdl/soap/methodDefCreator.rb +12 -16
- data/lib/wsdl/soap/servantSkeltonCreator.rb +3 -2
- data/lib/wsdl/soap/servletStubCreator.rb +107 -0
- data/lib/wsdl/soap/standaloneServerStubCreator.rb +10 -5
- data/lib/wsdl/soap/wsdl2ruby.rb +28 -13
- data/lib/wsdl/wsdl.rb +2 -1
- data/lib/wsdl/xmlSchema/anyAttribute.rb +48 -0
- data/lib/wsdl/xmlSchema/attributeGroup.rb +86 -0
- data/lib/wsdl/xmlSchema/choice.rb +4 -1
- data/lib/wsdl/xmlSchema/complexContent.rb +1 -1
- data/lib/wsdl/xmlSchema/complexExtension.rb +9 -1
- data/lib/wsdl/xmlSchema/complexRestriction.rb +8 -0
- data/lib/wsdl/xmlSchema/complexType.rb +38 -5
- data/lib/wsdl/xmlSchema/data.rb +30 -7
- data/lib/wsdl/xmlSchema/element.rb +10 -2
- data/lib/wsdl/xmlSchema/fractiondigits.rb +37 -0
- data/lib/wsdl/xmlSchema/group.rb +118 -0
- data/lib/wsdl/xmlSchema/import.rb +11 -23
- data/lib/wsdl/xmlSchema/importHandler.rb +45 -0
- data/lib/wsdl/xmlSchema/include.rb +11 -17
- data/lib/wsdl/xmlSchema/length.rb +3 -1
- data/lib/wsdl/xmlSchema/maxexclusive.rb +37 -0
- data/lib/wsdl/xmlSchema/maxinclusive.rb +37 -0
- data/lib/wsdl/xmlSchema/maxlength.rb +3 -1
- data/lib/wsdl/xmlSchema/minexclusive.rb +37 -0
- data/lib/wsdl/xmlSchema/mininclusive.rb +37 -0
- data/lib/wsdl/xmlSchema/minlength.rb +3 -1
- data/lib/wsdl/xmlSchema/schema.rb +34 -0
- data/lib/wsdl/xmlSchema/sequence.rb +4 -1
- data/lib/wsdl/xmlSchema/simpleExtension.rb +8 -0
- data/lib/wsdl/xmlSchema/simpleRestriction.rb +49 -8
- data/lib/wsdl/xmlSchema/totaldigits.rb +37 -0
- data/lib/wsdl/xmlSchema/whitespace.rb +37 -0
- data/lib/wsdl/xmlSchema/xsd2ruby.rb +13 -4
- data/lib/xsd/charset.rb +8 -6
- data/lib/xsd/codegen/classdef.rb +5 -0
- data/lib/xsd/codegen/moduledef.rb +17 -0
- data/lib/xsd/datatypes.rb +165 -20
- data/lib/xsd/mapping.rb +13 -5
- data/lib/xsd/namedelements.rb +8 -0
- data/lib/xsd/ns.rb +50 -14
- data/lib/xsd/qname.rb +3 -2
- data/lib/xsd/xmlparser.rb +4 -3
- data/test/soap/asp.net/test_aspdotnet.rb +1 -1
- data/test/soap/auth/test_basic.rb +4 -3
- data/test/soap/auth/test_digest.rb +4 -3
- data/test/soap/calc/test_calc.rb +6 -4
- data/test/soap/calc/test_calc2.rb +6 -4
- data/test/soap/calc/test_calc_cgi.rb +6 -4
- data/test/soap/fault/test_customfault.rb +6 -4
- data/test/soap/fault/test_soaparray.rb +35 -0
- data/test/soap/filter/test_filter.rb +2 -2
- data/test/soap/header/test_authheader.rb +2 -2
- data/test/soap/header/test_authheader_cgi.rb +3 -3
- data/test/soap/header/test_simplehandler.rb +2 -2
- data/test/soap/helloworld/test_helloworld.rb +6 -4
- data/test/soap/ssl/test_ssl.rb +1 -1
- data/test/soap/struct/test_struct.rb +2 -2
- data/test/soap/swa/test_file.rb +6 -4
- data/test/soap/test_basetype.rb +4 -4
- data/test/soap/test_cookie.rb +2 -2
- data/test/soap/test_custom_ns.rb +50 -8
- data/test/soap/test_custommap.rb +6 -4
- data/test/soap/test_empty.rb +6 -4
- data/test/soap/test_envelopenamespace.rb +2 -2
- data/test/soap/test_extraattr.rb +6 -7
- data/test/soap/test_generator.rb +27 -0
- data/test/soap/test_mapping.rb +10 -0
- data/test/soap/test_nestedexception.rb +56 -0
- data/test/soap/test_nil.rb +6 -4
- data/test/soap/test_no_indent.rb +6 -4
- data/test/soap/test_response_as_xml.rb +2 -2
- data/test/soap/test_streamhandler.rb +6 -3
- data/test/soap/test_styleuse.rb +2 -2
- data/test/soap/wsdlDriver/test_calc.rb +2 -2
- data/test/soap/wsdlDriver/test_document.rb +2 -2
- data/test/soap/wsdlDriver/test_simpletype.rb +2 -2
- data/test/wsdl/abstract/test_abstract.rb +1 -1
- data/test/wsdl/anonymous/expectedClassDef.rb +128 -0
- data/test/wsdl/anonymous/expectedDriver.rb +59 -0
- data/test/wsdl/anonymous/expectedMappingRegistry.rb +176 -0
- data/test/wsdl/anonymous/lp.wsdl +147 -0
- data/test/wsdl/anonymous/test_anonymous.rb +130 -0
- data/test/wsdl/any/expectedDriver.rb +3 -2
- data/test/wsdl/any/expectedEcho.rb +22 -2
- data/test/wsdl/any/expectedMappingRegistry.rb +63 -0
- data/test/wsdl/any/expectedService.rb +3 -1
- data/test/wsdl/any/test_any.rb +2 -7
- data/test/wsdl/axisArray/axisArray.wsdl +31 -4
- data/test/wsdl/axisArray/test_axisarray.rb +58 -3
- data/test/wsdl/choice/choice.wsdl +39 -0
- data/test/wsdl/choice/test_choice.rb +134 -7
- data/test/wsdl/complexcontent/test_echo.rb +1 -1
- data/test/wsdl/datetime/test_datetime.rb +2 -2
- data/test/wsdl/document/array/double.wsdl +45 -6
- data/test/wsdl/document/array/test_array.rb +68 -1
- data/test/wsdl/document/document.wsdl +2 -0
- data/test/wsdl/document/test_nosoapaction.rb +1 -1
- data/test/wsdl/document/test_number.rb +1 -1
- data/test/wsdl/document/test_rpc.rb +78 -9
- data/test/wsdl/fault/test_fault.rb +1 -1
- data/test/wsdl/fault/test_multifault.rb +1 -1
- data/test/wsdl/group/expectedClassdef.rb +58 -0
- data/test/wsdl/group/expectedDriver.rb +51 -0
- data/test/wsdl/group/expectedMappingRegistry.rb +67 -0
- data/test/wsdl/group/group.wsdl +88 -0
- data/test/wsdl/group/test_rpc.rb +145 -0
- data/test/wsdl/list/test_list.rb +1 -1
- data/test/wsdl/map/test_map.rb +2 -2
- data/test/wsdl/marshal/person_org.rb +5 -0
- data/test/wsdl/multiplefault.wsdl +11 -4
- data/test/wsdl/oneway/test_oneway.rb +1 -1
- data/test/wsdl/overload/test_overload.rb +1 -1
- data/test/wsdl/qualified/test_qualified.rb +1 -1
- data/test/wsdl/qualified/test_unqualified.rb +1 -1
- data/test/wsdl/raa/RAAService.rb +62 -57
- data/test/wsdl/raa/expectedClassDef.rb +100 -0
- data/test/wsdl/raa/expectedDriver.rb +96 -0
- data/test/wsdl/raa/expectedMappingRegistry.rb +121 -0
- data/test/wsdl/raa/test_raa.rb +54 -19
- data/test/wsdl/ref/expectedDriver.rb +1 -1
- data/test/wsdl/ref/expectedProduct.rb +101 -16
- data/test/wsdl/ref/test_ref.rb +2 -1
- data/test/wsdl/rpc/test_rpc.rb +1 -2
- data/test/wsdl/rpc/test_rpc_lit.rb +13 -13
- data/test/wsdl/simplecontent/test_simplecontent.rb +5 -5
- data/test/wsdl/simpletype/rpc/expectedDriver.rb +3 -2
- data/test/wsdl/simpletype/rpc/expectedEchoVersion.rb +2 -0
- data/test/wsdl/simpletype/rpc/expectedMappingRegistry.rb +10 -17
- data/test/wsdl/simpletype/rpc/expectedService.rb +4 -2
- data/test/wsdl/simpletype/test_simpletype.rb +2 -2
- data/test/wsdl/soap/test_soapbodyparts.rb +2 -2
- data/test/wsdl/soap/wsdl2ruby/expectedClassdef.rb +2 -0
- data/test/wsdl/soap/wsdl2ruby/expectedDriver.rb +3 -2
- data/test/wsdl/soap/wsdl2ruby/expectedMappingRegistry.rb +5 -9
- data/test/wsdl/soap/wsdl2ruby/expectedService.cgi +4 -2
- data/test/wsdl/soap/wsdl2ruby/expectedService.rb +4 -2
- data/test/wsdl/soap/wsdl2ruby/section/expectedClassdef.rb +6 -0
- data/test/wsdl/soap/wsdl2ruby/soapenc/test_soapenc.rb +1 -1
- data/test/wsdl/soaptype/test_soaptype.rb +1 -1
- data/test/wsdl/test_multiplefault.rb +3 -1
- data/test/xsd/codegen/test_classdef.rb +30 -0
- data/test/xsd/test_ns.rb +21 -0
- data/test/xsd/test_xsd.rb +5 -4
- data/test/xsd/xsd2ruby/expected_mysample.rb +13 -2
- data/test/xsd/xsd2ruby/expected_mysample_mapping_registry.rb +5 -11
- data/test/xsd/xsd2ruby/section.xsd +8 -0
- metadata +40 -8
- data/test/wsdl/axisArray/itemList.rb +0 -14
- data/test/wsdl/raa/RAA.rb +0 -120
- data/test/wsdl/raa/RAAServant.rb +0 -107
- data/test/wsdl/raa/server.rb +0 -103
data/lib/wsdl/definitions.rb
CHANGED
@@ -51,55 +51,28 @@ class Definitions < Info
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def collect_attributes
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
result
|
54
|
+
collect_imports(:collect_attributes)
|
55
|
+
end
|
56
|
+
|
57
|
+
def collect_modelgroups
|
58
|
+
collect_imports(:collect_modelgroups)
|
59
|
+
end
|
60
|
+
|
61
|
+
def collect_attributegroups
|
62
|
+
collect_imports(:collect_attributegroups)
|
64
63
|
end
|
65
64
|
|
66
65
|
def collect_elements
|
67
|
-
|
68
|
-
if @types
|
69
|
-
@types.schemas.each do |schema|
|
70
|
-
result.concat(schema.collect_elements)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
@imports.each do |import|
|
74
|
-
result.concat(import.content.collect_elements)
|
75
|
-
end
|
76
|
-
result
|
66
|
+
collect_imports(:collect_elements)
|
77
67
|
end
|
78
68
|
|
79
69
|
def collect_complextypes
|
80
|
-
result =
|
81
|
-
|
82
|
-
@types.schemas.each do |schema|
|
83
|
-
result.concat(schema.collect_complextypes)
|
84
|
-
end
|
85
|
-
end
|
86
|
-
@imports.each do |import|
|
87
|
-
result.concat(import.content.collect_complextypes)
|
88
|
-
end
|
89
|
-
result
|
70
|
+
result = collect_imports(:collect_complextypes)
|
71
|
+
@anontypes.dup.concat(result)
|
90
72
|
end
|
91
73
|
|
92
74
|
def collect_simpletypes
|
93
|
-
|
94
|
-
if @types
|
95
|
-
@types.schemas.each do |schema|
|
96
|
-
result.concat(schema.collect_simpletypes)
|
97
|
-
end
|
98
|
-
end
|
99
|
-
@imports.each do |import|
|
100
|
-
result.concat(import.content.collect_simpletypes)
|
101
|
-
end
|
102
|
-
result
|
75
|
+
collect_imports(:collect_simpletypes)
|
103
76
|
end
|
104
77
|
|
105
78
|
# ToDo: simpletype must be accepted...
|
@@ -244,6 +217,19 @@ class Definitions < Info
|
|
244
217
|
|
245
218
|
private
|
246
219
|
|
220
|
+
def collect_imports(method)
|
221
|
+
result = XSD::NamedElements.new
|
222
|
+
if @types
|
223
|
+
@types.schemas.each do |schema|
|
224
|
+
result.concat(schema.send(method))
|
225
|
+
end
|
226
|
+
end
|
227
|
+
@imports.each do |import|
|
228
|
+
result.concat(import.content.send(method))
|
229
|
+
end
|
230
|
+
result
|
231
|
+
end
|
232
|
+
|
247
233
|
end
|
248
234
|
|
249
235
|
|
data/lib/wsdl/info.rb
CHANGED
@@ -33,6 +33,17 @@ class Info
|
|
33
33
|
def parse_attr(attr, value); end # abstract
|
34
34
|
|
35
35
|
def parse_epilogue; end # abstract
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def to_int(value)
|
40
|
+
Integer(value.source)
|
41
|
+
end
|
42
|
+
|
43
|
+
def to_boolean(value)
|
44
|
+
s = value.source
|
45
|
+
s == "true" or s == "1"
|
46
|
+
end
|
36
47
|
end
|
37
48
|
|
38
49
|
|
data/lib/wsdl/parser.rb
CHANGED
@@ -7,10 +7,10 @@
|
|
7
7
|
|
8
8
|
|
9
9
|
require 'xsd/qname'
|
10
|
-
require 'xsd/ns'
|
11
10
|
require 'xsd/charset'
|
12
11
|
require 'xsd/datatypes'
|
13
12
|
require 'xsd/xmlparser'
|
13
|
+
require 'soap/ns'
|
14
14
|
require 'wsdl/wsdl'
|
15
15
|
require 'wsdl/data'
|
16
16
|
require 'wsdl/xmlSchema/data'
|
@@ -77,7 +77,7 @@ public
|
|
77
77
|
ns = lastframe.ns
|
78
78
|
parent = lastframe.node
|
79
79
|
else
|
80
|
-
ns =
|
80
|
+
ns = ::SOAP::NS.new
|
81
81
|
parent = nil
|
82
82
|
end
|
83
83
|
# ns might be the same
|
@@ -21,8 +21,9 @@ class CGIStubCreator
|
|
21
21
|
|
22
22
|
attr_reader :definitions
|
23
23
|
|
24
|
-
def initialize(definitions, modulepath = nil)
|
24
|
+
def initialize(definitions, name_creator, modulepath = nil)
|
25
25
|
@definitions = definitions
|
26
|
+
@name_creator = name_creator
|
26
27
|
@modulepath = modulepath
|
27
28
|
end
|
28
29
|
|
@@ -40,14 +41,15 @@ class CGIStubCreator
|
|
40
41
|
if port.porttype.nil?
|
41
42
|
raise RuntimeError.new("porttype not found for #{port}")
|
42
43
|
end
|
43
|
-
dump_porttype(port.porttype
|
44
|
+
dump_porttype(port.porttype)
|
44
45
|
end
|
45
46
|
|
46
47
|
private
|
47
48
|
|
48
|
-
def dump_porttype(
|
49
|
-
class_name =
|
50
|
-
|
49
|
+
def dump_porttype(porttype)
|
50
|
+
class_name = mapped_class_name(porttype.name, @modulepath)
|
51
|
+
defined_const = {}
|
52
|
+
result = MethodDefCreator.new(@definitions, @name_creator, @modulepath, defined_const).dump(porttype.name)
|
51
53
|
methoddef = result[:methoddef]
|
52
54
|
wsdl_name = @definitions.name ? @definitions.name.name : 'default'
|
53
55
|
mrname = safeconstname(wsdl_name + 'MappingRegistry')
|
@@ -58,6 +60,9 @@ Methods = [
|
|
58
60
|
#{methoddef.gsub(/^/, " ")}
|
59
61
|
]
|
60
62
|
EOD
|
63
|
+
defined_const.each do |ns, tag|
|
64
|
+
c1.def_const(tag, dq(ns))
|
65
|
+
end
|
61
66
|
c2 = XSD::CodeGen::ClassDef.new(class_name + "App",
|
62
67
|
"::SOAP::RPC::CGIStub")
|
63
68
|
c2.def_method("initialize", "*arg") do
|
@@ -9,6 +9,7 @@
|
|
9
9
|
require 'wsdl/data'
|
10
10
|
require 'wsdl/soap/classDefCreatorSupport'
|
11
11
|
require 'xsd/codegen'
|
12
|
+
require 'set'
|
12
13
|
|
13
14
|
|
14
15
|
module WSDL
|
@@ -19,8 +20,9 @@ class ClassDefCreator
|
|
19
20
|
include ClassDefCreatorSupport
|
20
21
|
include XSD::CodeGen
|
21
22
|
|
22
|
-
def initialize(definitions, modulepath = nil)
|
23
|
+
def initialize(definitions, name_creator, modulepath = nil)
|
23
24
|
@definitions = definitions
|
25
|
+
@name_creator = name_creator
|
24
26
|
@modulepath = modulepath
|
25
27
|
@elements = definitions.collect_elements
|
26
28
|
@elements.uniq!
|
@@ -30,22 +32,31 @@ class ClassDefCreator
|
|
30
32
|
@simpletypes.uniq!
|
31
33
|
@complextypes = definitions.collect_complextypes
|
32
34
|
@complextypes.uniq!
|
35
|
+
@modelgroups = definitions.collect_modelgroups
|
36
|
+
@modelgroups.uniq!
|
33
37
|
@faulttypes = nil
|
34
38
|
if definitions.respond_to?(:collect_faulttypes)
|
35
39
|
@faulttypes = definitions.collect_faulttypes
|
36
40
|
end
|
41
|
+
@defined_const = {}
|
37
42
|
end
|
38
43
|
|
39
44
|
def dump(type = nil)
|
40
45
|
result = "require 'xsd/qname'\n"
|
46
|
+
# cannot use @modulepath because of multiple classes
|
41
47
|
if @modulepath
|
42
48
|
result << "\n"
|
43
|
-
result << @modulepath.collect { |ele| "module #{ele}" }.join("; ")
|
49
|
+
result << modulepath_split(@modulepath).collect { |ele| "module #{ele}" }.join("; ")
|
44
50
|
result << "\n\n"
|
45
51
|
end
|
46
52
|
if type
|
47
53
|
result << dump_classdef(type.name, type)
|
48
54
|
else
|
55
|
+
str = dump_group
|
56
|
+
unless str.empty?
|
57
|
+
result << "\n" unless result.empty?
|
58
|
+
result << str
|
59
|
+
end
|
49
60
|
str = dump_complextype
|
50
61
|
unless str.empty?
|
51
62
|
result << "\n" unless result.empty?
|
@@ -69,7 +80,7 @@ class ClassDefCreator
|
|
69
80
|
end
|
70
81
|
if @modulepath
|
71
82
|
result << "\n\n"
|
72
|
-
result << @modulepath.collect { |ele| "end" }.join("; ")
|
83
|
+
result << modulepath_split(@modulepath).collect { |ele| "end" }.join("; ")
|
73
84
|
result << "\n"
|
74
85
|
end
|
75
86
|
result
|
@@ -79,69 +90,83 @@ private
|
|
79
90
|
|
80
91
|
def dump_element
|
81
92
|
@elements.collect { |ele|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
elsif ele.local_simpletype
|
86
|
-
dump_simpletypedef(ele.name, ele.local_simpletype, qualified)
|
87
|
-
elsif ele.empty?
|
88
|
-
dump_simpleclassdef(ele.name, nil)
|
89
|
-
else
|
90
|
-
nil
|
91
|
-
end
|
93
|
+
next if @complextypes[ele.name]
|
94
|
+
c = create_elementdef(@modulepath, ele)
|
95
|
+
c ? c.dump : nil
|
92
96
|
}.compact.join("\n")
|
93
97
|
end
|
94
98
|
|
95
99
|
def dump_attribute
|
96
|
-
@attributes.collect { |
|
97
|
-
if
|
98
|
-
|
100
|
+
@attributes.collect { |attribute|
|
101
|
+
if attribute.local_simpletype
|
102
|
+
c = create_simpletypedef(@modulepath, attribute.name, attribute.local_simpletype)
|
99
103
|
end
|
104
|
+
c ? c.dump : nil
|
100
105
|
}.compact.join("\n")
|
101
106
|
end
|
102
107
|
|
103
108
|
def dump_simpletype
|
104
109
|
@simpletypes.collect { |type|
|
105
|
-
|
110
|
+
c = create_simpletypedef(@modulepath, type.name, type)
|
111
|
+
c ? c.dump : nil
|
106
112
|
}.compact.join("\n")
|
107
113
|
end
|
108
114
|
|
109
115
|
def dump_complextype
|
110
116
|
definitions = sort_dependency(@complextypes).collect { |type|
|
111
|
-
|
117
|
+
c = create_complextypedef(@modulepath, type.name, type)
|
118
|
+
c ? c.dump : nil
|
119
|
+
}.compact.join("\n")
|
120
|
+
end
|
121
|
+
|
122
|
+
def dump_group
|
123
|
+
definitions = @modelgroups.collect { |group|
|
124
|
+
# TODO: not dumped for now but may be useful in the future
|
112
125
|
}.compact.join("\n")
|
113
126
|
end
|
114
127
|
|
115
|
-
def
|
128
|
+
def create_elementdef(mpath, ele)
|
129
|
+
qualified = (ele.elementform == 'qualified')
|
130
|
+
if ele.local_complextype
|
131
|
+
create_complextypedef(mpath, ele.name, ele.local_complextype, qualified)
|
132
|
+
elsif ele.local_simpletype
|
133
|
+
create_simpletypedef(mpath, ele.name, ele.local_simpletype, qualified)
|
134
|
+
elsif ele.empty?
|
135
|
+
create_simpleclassdef(mpath, ele.name, nil)
|
136
|
+
else
|
137
|
+
# ignores type only element
|
138
|
+
nil
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
def create_simpletypedef(mpath, qname, simpletype, qualified = false)
|
116
143
|
if simpletype.restriction
|
117
|
-
|
144
|
+
create_simpletypedef_restriction(mpath, qname, simpletype, qualified)
|
118
145
|
elsif simpletype.list
|
119
|
-
|
146
|
+
create_simpletypedef_list(mpath, qname, simpletype, qualified)
|
120
147
|
elsif simpletype.union
|
121
|
-
|
148
|
+
create_simpletypedef_union(mpath, qname, simpletype, qualified)
|
122
149
|
else
|
123
150
|
raise RuntimeError.new("unknown kind of simpletype: #{simpletype}")
|
124
151
|
end
|
125
152
|
end
|
126
153
|
|
127
|
-
def
|
154
|
+
def create_simpletypedef_restriction(mpath, qname, typedef, qualified)
|
128
155
|
restriction = typedef.restriction
|
129
|
-
|
156
|
+
unless restriction.enumeration?
|
130
157
|
# not supported. minlength?
|
131
158
|
return nil
|
132
159
|
end
|
133
|
-
classname =
|
134
|
-
check_classname(classname)
|
160
|
+
classname = mapped_class_basename(qname, mpath)
|
135
161
|
c = ClassDef.new(classname, '::String')
|
136
162
|
c.comment = "#{qname}"
|
137
163
|
define_classenum_restriction(c, classname, restriction.enumeration)
|
138
|
-
c
|
164
|
+
c
|
139
165
|
end
|
140
166
|
|
141
|
-
def
|
167
|
+
def create_simpletypedef_list(mpath, qname, typedef, qualified)
|
142
168
|
list = typedef.list
|
143
|
-
classname =
|
144
|
-
check_classname(classname)
|
169
|
+
classname = mapped_class_basename(qname, mpath)
|
145
170
|
c = ClassDef.new(classname, '::Array')
|
146
171
|
c.comment = "#{qname}"
|
147
172
|
if simpletype = list.local_simpletype
|
@@ -152,22 +177,23 @@ private
|
|
152
177
|
define_stringenum_restriction(c, simpletype.restriction.enumeration)
|
153
178
|
c.comment << "\n contains list of #{classname}::*"
|
154
179
|
elsif list.itemtype
|
155
|
-
c.comment << "\n contains list of #{
|
180
|
+
c.comment << "\n contains list of #{mapped_class_basename(list.itemtype, mpath)}::*"
|
156
181
|
else
|
157
182
|
raise RuntimeError.new("unknown kind of list: #{list}")
|
158
183
|
end
|
159
|
-
c
|
184
|
+
c
|
160
185
|
end
|
161
186
|
|
162
|
-
def
|
187
|
+
def create_simpletypedef_union(mpath, qname, typedef, qualified)
|
163
188
|
union = typedef.union
|
164
|
-
|
189
|
+
classname = mapped_class_basename(qname, mpath)
|
190
|
+
c = ClassDef.new(classname, '::String')
|
165
191
|
c.comment = "#{qname}"
|
166
192
|
if union.member_types
|
167
193
|
# fixme
|
168
194
|
c.comment << "\n any of #{union.member_types}"
|
169
195
|
end
|
170
|
-
c
|
196
|
+
c
|
171
197
|
end
|
172
198
|
|
173
199
|
def define_stringenum_restriction(c, enumeration)
|
@@ -194,9 +220,8 @@ private
|
|
194
220
|
end
|
195
221
|
end
|
196
222
|
|
197
|
-
def
|
198
|
-
classname =
|
199
|
-
check_classname(classname)
|
223
|
+
def create_simpleclassdef(mpath, qname, type_or_element)
|
224
|
+
classname = mapped_class_basename(qname, mpath)
|
200
225
|
c = ClassDef.new(classname, '::String')
|
201
226
|
c.comment = "#{qname}"
|
202
227
|
init_lines = []
|
@@ -207,17 +232,17 @@ private
|
|
207
232
|
c.def_method('initialize', '*arg') do
|
208
233
|
"super\n" + init_lines.join("\n")
|
209
234
|
end
|
210
|
-
c
|
235
|
+
c
|
211
236
|
end
|
212
237
|
|
213
|
-
def
|
238
|
+
def create_complextypedef(mpath, qname, type, qualified = false)
|
214
239
|
case type.compoundtype
|
215
240
|
when :TYPE_STRUCT, :TYPE_EMPTY
|
216
|
-
|
241
|
+
create_structdef(mpath, qname, type, qualified)
|
217
242
|
when :TYPE_ARRAY
|
218
|
-
|
243
|
+
create_arraydef(mpath, qname, type)
|
219
244
|
when :TYPE_SIMPLE
|
220
|
-
|
245
|
+
create_simpleclassdef(mpath, qname, type)
|
221
246
|
when :TYPE_MAP
|
222
247
|
# mapped as a general Hash
|
223
248
|
nil
|
@@ -227,13 +252,17 @@ private
|
|
227
252
|
end
|
228
253
|
end
|
229
254
|
|
230
|
-
def
|
231
|
-
classname =
|
232
|
-
check_classname(classname)
|
255
|
+
def create_structdef(mpath, qname, typedef, qualified = false)
|
256
|
+
classname = mapped_class_basename(qname, mpath)
|
233
257
|
baseclassname = nil
|
234
258
|
if typedef.complexcontent
|
235
259
|
if base = typedef.complexcontent.base
|
236
|
-
|
260
|
+
# :TYPE_ARRAY must not be derived (#424)
|
261
|
+
basedef = @complextypes[base]
|
262
|
+
if basedef and basedef.compoundtype != :TYPE_ARRAY
|
263
|
+
# baseclass should be a toplevel complexType
|
264
|
+
baseclassname = mapped_class_basename(base, @modulepath)
|
265
|
+
end
|
237
266
|
end
|
238
267
|
end
|
239
268
|
if @faulttypes and @faulttypes.index(qname)
|
@@ -243,8 +272,9 @@ private
|
|
243
272
|
end
|
244
273
|
c.comment = "#{qname}"
|
245
274
|
c.comment << "\nabstract" if typedef.abstract
|
275
|
+
parentmodule = mapped_class_name(qname, mpath)
|
246
276
|
init_lines, init_params =
|
247
|
-
parse_elements(c, typedef.elements, qname.namespace)
|
277
|
+
parse_elements(c, typedef.elements, qname.namespace, parentmodule)
|
248
278
|
unless typedef.attributes.empty?
|
249
279
|
define_attribute(c, typedef.attributes)
|
250
280
|
init_lines << "@__xmlattr = {}"
|
@@ -252,10 +282,10 @@ private
|
|
252
282
|
c.def_method('initialize', *init_params) do
|
253
283
|
init_lines.join("\n")
|
254
284
|
end
|
255
|
-
c
|
285
|
+
c
|
256
286
|
end
|
257
287
|
|
258
|
-
def parse_elements(c, elements, base_namespace)
|
288
|
+
def parse_elements(c, elements, base_namespace, mpath, as_array = false)
|
259
289
|
init_lines = []
|
260
290
|
init_params = []
|
261
291
|
any = false
|
@@ -274,23 +304,44 @@ private
|
|
274
304
|
when XMLSchema::Element
|
275
305
|
next if element.ref == SchemaName
|
276
306
|
name = name_element(element).name
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
307
|
+
typebase = @modulepath
|
308
|
+
if element.anonymous_type?
|
309
|
+
inner = create_elementdef(mpath, element)
|
310
|
+
unless as_array
|
311
|
+
inner.comment = "inner class for member: #{name}\n" + inner.comment
|
312
|
+
end
|
313
|
+
c.innermodule << inner
|
314
|
+
typebase = mpath
|
315
|
+
end
|
316
|
+
unless as_array
|
317
|
+
attrname = safemethodname(name)
|
318
|
+
varname = safevarname(name)
|
319
|
+
c.def_attr(attrname, true, varname)
|
320
|
+
init_lines << "@#{varname} = #{varname}"
|
321
|
+
if element.map_as_array?
|
322
|
+
init_params << "#{varname} = []"
|
323
|
+
else
|
324
|
+
init_params << "#{varname} = nil"
|
325
|
+
end
|
326
|
+
c.comment << "\n #{attrname} - #{create_type_name(typebase, element) || '(any)'}"
|
285
327
|
end
|
286
328
|
when WSDL::XMLSchema::Sequence
|
287
329
|
child_init_lines, child_init_params =
|
288
|
-
parse_elements(c, element.elements, base_namespace)
|
330
|
+
parse_elements(c, element.elements, base_namespace, mpath, as_array)
|
289
331
|
init_lines.concat(child_init_lines)
|
290
332
|
init_params.concat(child_init_params)
|
291
333
|
when WSDL::XMLSchema::Choice
|
292
334
|
child_init_lines, child_init_params =
|
293
|
-
parse_elements(c, element.elements, base_namespace)
|
335
|
+
parse_elements(c, element.elements, base_namespace, mpath, as_array)
|
336
|
+
init_lines.concat(child_init_lines)
|
337
|
+
init_params.concat(child_init_params)
|
338
|
+
when WSDL::XMLSchema::Group
|
339
|
+
if element.content.nil?
|
340
|
+
warn("no group definition found: #{element}")
|
341
|
+
next
|
342
|
+
end
|
343
|
+
child_init_lines, child_init_params =
|
344
|
+
parse_elements(c, element.content.elements, base_namespace, mpath, as_array)
|
294
345
|
init_lines.concat(child_init_lines)
|
295
346
|
init_params.concat(child_init_params)
|
296
347
|
else
|
@@ -300,74 +351,42 @@ private
|
|
300
351
|
[init_lines, init_params]
|
301
352
|
end
|
302
353
|
|
303
|
-
def element_basetype(ele)
|
304
|
-
if klass = basetype_class(ele.type)
|
305
|
-
klass
|
306
|
-
elsif ele.local_simpletype
|
307
|
-
basetype_class(ele.local_simpletype.base)
|
308
|
-
else
|
309
|
-
nil
|
310
|
-
end
|
311
|
-
end
|
312
|
-
|
313
|
-
def attribute_basetype(attr)
|
314
|
-
if klass = basetype_class(attr.type)
|
315
|
-
klass
|
316
|
-
elsif attr.local_simpletype
|
317
|
-
basetype_class(attr.local_simpletype.base)
|
318
|
-
else
|
319
|
-
nil
|
320
|
-
end
|
321
|
-
end
|
322
|
-
|
323
|
-
def basetype_class(type)
|
324
|
-
return nil if type.nil?
|
325
|
-
if simpletype = @simpletypes[type]
|
326
|
-
basetype_mapped_class(simpletype.base)
|
327
|
-
else
|
328
|
-
basetype_mapped_class(type)
|
329
|
-
end
|
330
|
-
end
|
331
|
-
|
332
354
|
def define_attribute(c, attributes)
|
355
|
+
const = {}
|
356
|
+
unless attributes.empty?
|
357
|
+
c.def_method("__xmlattr") do <<-__EOD__
|
358
|
+
@__xmlattr ||= {}
|
359
|
+
__EOD__
|
360
|
+
end
|
361
|
+
end
|
333
362
|
attributes.each do |attribute|
|
334
363
|
name = name_attribute(attribute)
|
335
364
|
methodname = safemethodname('xmlattr_' + name.name)
|
365
|
+
constname = 'Attr' + safeconstname(name.name)
|
366
|
+
const[constname] ||= 0
|
367
|
+
if (const[constname] += 1) > 1
|
368
|
+
constname += "_#{const[constname]}"
|
369
|
+
end
|
370
|
+
c.def_const(constname, dqname(name))
|
336
371
|
c.def_method(methodname) do <<-__EOD__
|
337
|
-
|
372
|
+
__xmlattr[#{constname}]
|
338
373
|
__EOD__
|
339
374
|
end
|
340
375
|
c.def_method(methodname + '=', 'value') do <<-__EOD__
|
341
|
-
|
376
|
+
__xmlattr[#{constname}] = value
|
342
377
|
__EOD__
|
343
378
|
end
|
379
|
+
c.comment << "\n #{methodname} - #{attribute_basetype(attribute) || '(any)'}"
|
344
380
|
end
|
345
381
|
end
|
346
382
|
|
347
|
-
def
|
348
|
-
|
349
|
-
return element.ref if element.ref
|
350
|
-
raise RuntimeError.new("cannot define name of #{element}")
|
351
|
-
end
|
352
|
-
|
353
|
-
def name_attribute(attribute)
|
354
|
-
return attribute.name if attribute.name
|
355
|
-
return attribute.ref if attribute.ref
|
356
|
-
raise RuntimeError.new("cannot define name of #{attribute}")
|
357
|
-
end
|
358
|
-
|
359
|
-
def dump_arraydef(qname, complextype)
|
360
|
-
classname = create_class_name(qname)
|
361
|
-
check_classname(classname)
|
383
|
+
def create_arraydef(mpath, qname, typedef)
|
384
|
+
classname = mapped_class_basename(qname, mpath)
|
362
385
|
c = ClassDef.new(classname, '::Array')
|
363
386
|
c.comment = "#{qname}"
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
def check_classname(classname)
|
368
|
-
if @modulepath.nil? and Object.constants.include?(classname)
|
369
|
-
warn("created definition re-opens an existing toplevel class: #{classname}")
|
370
|
-
end
|
387
|
+
parentmodule = mapped_class_name(qname, mpath)
|
388
|
+
parse_elements(c, typedef.elements, qname.namespace, parentmodule, true)
|
389
|
+
c
|
371
390
|
end
|
372
391
|
|
373
392
|
def sort_dependency(types)
|
@@ -399,6 +418,14 @@ private
|
|
399
418
|
dep.delete(type.name)
|
400
419
|
result
|
401
420
|
end
|
421
|
+
|
422
|
+
def modulepath_split(modulepath)
|
423
|
+
if modulepath.is_a?(::Array)
|
424
|
+
modulepath
|
425
|
+
else
|
426
|
+
modulepath.to_s.split('::')
|
427
|
+
end
|
428
|
+
end
|
402
429
|
end
|
403
430
|
|
404
431
|
|