reidiculous-actionwebservice-client 3.0.4
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 +320 -0
- data/MIT-LICENSE +21 -0
- data/README +381 -0
- data/Rakefile +180 -0
- data/TODO +32 -0
- data/lib/action_web_service.rb +71 -0
- data/lib/action_web_service/api.rb +297 -0
- data/lib/action_web_service/base.rb +38 -0
- data/lib/action_web_service/casting.rb +149 -0
- data/lib/action_web_service/client.rb +3 -0
- data/lib/action_web_service/client/base.rb +28 -0
- data/lib/action_web_service/client/soap_client.rb +113 -0
- data/lib/action_web_service/client/xmlrpc_client.rb +58 -0
- data/lib/action_web_service/container.rb +3 -0
- data/lib/action_web_service/container/action_controller_container.rb +93 -0
- data/lib/action_web_service/container/delegated_container.rb +86 -0
- data/lib/action_web_service/container/direct_container.rb +69 -0
- data/lib/action_web_service/dispatcher.rb +2 -0
- data/lib/action_web_service/dispatcher/abstract.rb +207 -0
- data/lib/action_web_service/dispatcher/action_controller_dispatcher.rb +379 -0
- data/lib/action_web_service/invocation.rb +202 -0
- data/lib/action_web_service/protocol.rb +4 -0
- data/lib/action_web_service/protocol/abstract.rb +115 -0
- data/lib/action_web_service/protocol/discovery.rb +37 -0
- data/lib/action_web_service/protocol/soap_protocol.rb +176 -0
- data/lib/action_web_service/protocol/soap_protocol/marshaler.rb +242 -0
- data/lib/action_web_service/protocol/xmlrpc_protocol.rb +122 -0
- data/lib/action_web_service/scaffolding.rb +281 -0
- data/lib/action_web_service/soap/attachment.rb +107 -0
- data/lib/action_web_service/soap/baseData.rb +942 -0
- data/lib/action_web_service/soap/element.rb +258 -0
- data/lib/action_web_service/soap/encodingstyle/aspDotNetHandler.rb +213 -0
- data/lib/action_web_service/soap/encodingstyle/handler.rb +100 -0
- data/lib/action_web_service/soap/encodingstyle/literalHandler.rb +226 -0
- data/lib/action_web_service/soap/encodingstyle/soapHandler.rb +582 -0
- data/lib/action_web_service/soap/generator.rb +268 -0
- data/lib/action_web_service/soap/header/handler.rb +57 -0
- data/lib/action_web_service/soap/header/handlerset.rb +70 -0
- data/lib/action_web_service/soap/header/simplehandler.rb +44 -0
- data/lib/action_web_service/soap/httpconfigloader.rb +119 -0
- data/lib/action_web_service/soap/mapping.rb +10 -0
- data/lib/action_web_service/soap/mapping/factory.rb +355 -0
- data/lib/action_web_service/soap/mapping/mapping.rb +381 -0
- data/lib/action_web_service/soap/mapping/registry.rb +541 -0
- data/lib/action_web_service/soap/mapping/rubytypeFactory.rb +475 -0
- data/lib/action_web_service/soap/mapping/typeMap.rb +50 -0
- data/lib/action_web_service/soap/mapping/wsdlencodedregistry.rb +280 -0
- data/lib/action_web_service/soap/mapping/wsdlliteralregistry.rb +418 -0
- data/lib/action_web_service/soap/marshal.rb +59 -0
- data/lib/action_web_service/soap/mimemessage.rb +240 -0
- data/lib/action_web_service/soap/netHttpClient.rb +190 -0
- data/lib/action_web_service/soap/parser.rb +251 -0
- data/lib/action_web_service/soap/processor.rb +66 -0
- data/lib/action_web_service/soap/property.rb +333 -0
- data/lib/action_web_service/soap/rpc/cgistub.rb +206 -0
- data/lib/action_web_service/soap/rpc/driver.rb +254 -0
- data/lib/action_web_service/soap/rpc/element.rb +325 -0
- data/lib/action_web_service/soap/rpc/httpserver.rb +129 -0
- data/lib/action_web_service/soap/rpc/proxy.rb +497 -0
- data/lib/action_web_service/soap/rpc/router.rb +594 -0
- data/lib/action_web_service/soap/rpc/rpc.rb +25 -0
- data/lib/action_web_service/soap/rpc/soaplet.rb +162 -0
- data/lib/action_web_service/soap/rpc/standaloneServer.rb +43 -0
- data/lib/action_web_service/soap/soap.rb +140 -0
- data/lib/action_web_service/soap/streamHandler.rb +229 -0
- data/lib/action_web_service/soap/wsdlDriver.rb +575 -0
- data/lib/action_web_service/struct.rb +64 -0
- data/lib/action_web_service/support/class_inheritable_options.rb +28 -0
- data/lib/action_web_service/support/signature_types.rb +227 -0
- data/lib/action_web_service/test_invoke.rb +110 -0
- data/lib/action_web_service/version.rb +9 -0
- data/lib/action_web_service/wsdl/binding.rb +65 -0
- data/lib/action_web_service/wsdl/data.rb +64 -0
- data/lib/action_web_service/wsdl/definitions.rb +250 -0
- data/lib/action_web_service/wsdl/documentation.rb +32 -0
- data/lib/action_web_service/wsdl/import.rb +80 -0
- data/lib/action_web_service/wsdl/importer.rb +38 -0
- data/lib/action_web_service/wsdl/info.rb +39 -0
- data/lib/action_web_service/wsdl/message.rb +54 -0
- data/lib/action_web_service/wsdl/operation.rb +130 -0
- data/lib/action_web_service/wsdl/operationBinding.rb +108 -0
- data/lib/action_web_service/wsdl/param.rb +85 -0
- data/lib/action_web_service/wsdl/parser.rb +163 -0
- data/lib/action_web_service/wsdl/part.rb +52 -0
- data/lib/action_web_service/wsdl/port.rb +84 -0
- data/lib/action_web_service/wsdl/portType.rb +73 -0
- data/lib/action_web_service/wsdl/service.rb +61 -0
- data/lib/action_web_service/wsdl/soap/address.rb +40 -0
- data/lib/action_web_service/wsdl/soap/binding.rb +49 -0
- data/lib/action_web_service/wsdl/soap/body.rb +56 -0
- data/lib/action_web_service/wsdl/soap/cgiStubCreator.rb +76 -0
- data/lib/action_web_service/wsdl/soap/classDefCreator.rb +314 -0
- data/lib/action_web_service/wsdl/soap/classDefCreatorSupport.rb +126 -0
- data/lib/action_web_service/wsdl/soap/clientSkeltonCreator.rb +78 -0
- data/lib/action_web_service/wsdl/soap/complexType.rb +161 -0
- data/lib/action_web_service/wsdl/soap/data.rb +42 -0
- data/lib/action_web_service/wsdl/soap/definitions.rb +149 -0
- data/lib/action_web_service/wsdl/soap/driverCreator.rb +95 -0
- data/lib/action_web_service/wsdl/soap/element.rb +28 -0
- data/lib/action_web_service/wsdl/soap/fault.rb +56 -0
- data/lib/action_web_service/wsdl/soap/header.rb +86 -0
- data/lib/action_web_service/wsdl/soap/headerfault.rb +56 -0
- data/lib/action_web_service/wsdl/soap/mappingRegistryCreator.rb +92 -0
- data/lib/action_web_service/wsdl/soap/methodDefCreator.rb +228 -0
- data/lib/action_web_service/wsdl/soap/operation.rb +122 -0
- data/lib/action_web_service/wsdl/soap/servantSkeltonCreator.rb +67 -0
- data/lib/action_web_service/wsdl/soap/standaloneServerStubCreator.rb +85 -0
- data/lib/action_web_service/wsdl/soap/wsdl2ruby.rb +176 -0
- data/lib/action_web_service/wsdl/types.rb +43 -0
- data/lib/action_web_service/wsdl/wsdl.rb +23 -0
- data/lib/action_web_service/wsdl/xmlSchema/all.rb +69 -0
- data/lib/action_web_service/wsdl/xmlSchema/annotation.rb +34 -0
- data/lib/action_web_service/wsdl/xmlSchema/any.rb +56 -0
- data/lib/action_web_service/wsdl/xmlSchema/attribute.rb +127 -0
- data/lib/action_web_service/wsdl/xmlSchema/choice.rb +69 -0
- data/lib/action_web_service/wsdl/xmlSchema/complexContent.rb +92 -0
- data/lib/action_web_service/wsdl/xmlSchema/complexType.rb +139 -0
- data/lib/action_web_service/wsdl/xmlSchema/content.rb +96 -0
- data/lib/action_web_service/wsdl/xmlSchema/data.rb +80 -0
- data/lib/action_web_service/wsdl/xmlSchema/element.rb +154 -0
- data/lib/action_web_service/wsdl/xmlSchema/enumeration.rb +36 -0
- data/lib/action_web_service/wsdl/xmlSchema/import.rb +65 -0
- data/lib/action_web_service/wsdl/xmlSchema/importer.rb +87 -0
- data/lib/action_web_service/wsdl/xmlSchema/include.rb +54 -0
- data/lib/action_web_service/wsdl/xmlSchema/length.rb +35 -0
- data/lib/action_web_service/wsdl/xmlSchema/parser.rb +166 -0
- data/lib/action_web_service/wsdl/xmlSchema/pattern.rb +36 -0
- data/lib/action_web_service/wsdl/xmlSchema/schema.rb +143 -0
- data/lib/action_web_service/wsdl/xmlSchema/sequence.rb +69 -0
- data/lib/action_web_service/wsdl/xmlSchema/simpleContent.rb +65 -0
- data/lib/action_web_service/wsdl/xmlSchema/simpleExtension.rb +54 -0
- data/lib/action_web_service/wsdl/xmlSchema/simpleRestriction.rb +73 -0
- data/lib/action_web_service/wsdl/xmlSchema/simpleType.rb +73 -0
- data/lib/action_web_service/wsdl/xmlSchema/unique.rb +34 -0
- data/lib/action_web_service/wsdl/xmlSchema/xsd2ruby.rb +107 -0
- data/lib/action_web_service/xsd/charset.rb +187 -0
- data/lib/action_web_service/xsd/codegen.rb +12 -0
- data/lib/action_web_service/xsd/codegen/classdef.rb +203 -0
- data/lib/action_web_service/xsd/codegen/commentdef.rb +34 -0
- data/lib/action_web_service/xsd/codegen/gensupport.rb +166 -0
- data/lib/action_web_service/xsd/codegen/methoddef.rb +63 -0
- data/lib/action_web_service/xsd/codegen/moduledef.rb +191 -0
- data/lib/action_web_service/xsd/datatypes.rb +1269 -0
- data/lib/action_web_service/xsd/datatypes1999.rb +20 -0
- data/lib/action_web_service/xsd/iconvcharset.rb +33 -0
- data/lib/action_web_service/xsd/mapping.rb +42 -0
- data/lib/action_web_service/xsd/namedelements.rb +95 -0
- data/lib/action_web_service/xsd/ns.rb +140 -0
- data/lib/action_web_service/xsd/qname.rb +78 -0
- data/lib/action_web_service/xsd/xmlparser.rb +61 -0
- data/lib/action_web_service/xsd/xmlparser/parser.rb +96 -0
- data/lib/action_web_service/xsd/xmlparser/rexmlparser.rb +54 -0
- data/lib/action_web_service/xsd/xmlparser/xmlparser.rb +50 -0
- data/lib/action_web_service/xsd/xmlparser/xmlscanner.rb +147 -0
- data/lib/actionwebservice.rb +1 -0
- data/setup.rb +1379 -0
- data/test/abstract_client.rb +183 -0
- data/test/abstract_dispatcher.rb +548 -0
- data/test/abstract_unit.rb +45 -0
- data/test/api_test.rb +103 -0
- data/test/apis/auto_load_api.rb +3 -0
- data/test/apis/broken_auto_load_api.rb +2 -0
- data/test/base_test.rb +42 -0
- data/test/casting_test.rb +95 -0
- data/test/client_soap_test.rb +156 -0
- data/test/client_xmlrpc_test.rb +153 -0
- data/test/container_test.rb +73 -0
- data/test/dispatcher_action_controller_soap_test.rb +139 -0
- data/test/dispatcher_action_controller_xmlrpc_test.rb +59 -0
- data/test/fixtures/db_definitions/mysql.sql +8 -0
- data/test/fixtures/db_definitions/sqlite3.sql +8 -0
- data/test/fixtures/users.yml +12 -0
- data/test/gencov +3 -0
- data/test/invocation_test.rb +185 -0
- data/test/run +6 -0
- data/test/scaffolded_controller_test.rb +146 -0
- data/test/struct_test.rb +52 -0
- data/test/test_invoke_test.rb +112 -0
- metadata +265 -0
@@ -0,0 +1,314 @@
|
|
1
|
+
# WSDL4R - Creating class definition from WSDL
|
2
|
+
# Copyright (C) 2002, 2003, 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
3
|
+
|
4
|
+
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
5
|
+
# redistribute it and/or modify it under the same terms of Ruby's license;
|
6
|
+
# either the dual license version in 2003, or any later version.
|
7
|
+
|
8
|
+
|
9
|
+
require 'action_web_service/wsdl/data'
|
10
|
+
require 'action_web_service/wsdl/soap/classDefCreatorSupport'
|
11
|
+
require 'action_web_service/xsd/codegen'
|
12
|
+
|
13
|
+
|
14
|
+
module WSDL
|
15
|
+
module SOAP
|
16
|
+
|
17
|
+
|
18
|
+
class ClassDefCreator
|
19
|
+
include ClassDefCreatorSupport
|
20
|
+
|
21
|
+
def initialize(definitions)
|
22
|
+
@elements = definitions.collect_elements
|
23
|
+
@simpletypes = definitions.collect_simpletypes
|
24
|
+
@complextypes = definitions.collect_complextypes
|
25
|
+
@faulttypes = nil
|
26
|
+
if definitions.respond_to?(:collect_faulttypes)
|
27
|
+
@faulttypes = definitions.collect_faulttypes
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def dump(type = nil)
|
32
|
+
result = "require 'action_web_service/xsd/qname'\n"
|
33
|
+
if type
|
34
|
+
result = dump_classdef(type.name, type)
|
35
|
+
else
|
36
|
+
str = dump_element
|
37
|
+
unless str.empty?
|
38
|
+
result << "\n" unless result.empty?
|
39
|
+
result << str
|
40
|
+
end
|
41
|
+
str = dump_complextype
|
42
|
+
unless str.empty?
|
43
|
+
result << "\n" unless result.empty?
|
44
|
+
result << str
|
45
|
+
end
|
46
|
+
str = dump_simpletype
|
47
|
+
unless str.empty?
|
48
|
+
result << "\n" unless result.empty?
|
49
|
+
result << str
|
50
|
+
end
|
51
|
+
end
|
52
|
+
result
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def dump_element
|
58
|
+
@elements.collect { |ele|
|
59
|
+
if ele.local_complextype
|
60
|
+
dump_classdef(ele.name, ele.local_complextype,
|
61
|
+
ele.elementform == 'qualified')
|
62
|
+
elsif ele.local_simpletype
|
63
|
+
dump_simpletypedef(ele.name, ele.local_simpletype)
|
64
|
+
else
|
65
|
+
nil
|
66
|
+
end
|
67
|
+
}.compact.join("\n")
|
68
|
+
end
|
69
|
+
|
70
|
+
def dump_simpletype
|
71
|
+
@simpletypes.collect { |type|
|
72
|
+
dump_simpletypedef(type.name, type)
|
73
|
+
}.compact.join("\n")
|
74
|
+
end
|
75
|
+
|
76
|
+
def dump_complextype
|
77
|
+
@complextypes.collect { |type|
|
78
|
+
case type.compoundtype
|
79
|
+
when :TYPE_STRUCT, :TYPE_EMPTY
|
80
|
+
dump_classdef(type.name, type)
|
81
|
+
when :TYPE_ARRAY
|
82
|
+
dump_arraydef(type)
|
83
|
+
when :TYPE_SIMPLE
|
84
|
+
dump_simpleclassdef(type)
|
85
|
+
when :TYPE_MAP
|
86
|
+
# mapped as a general Hash
|
87
|
+
nil
|
88
|
+
else
|
89
|
+
raise RuntimeError.new(
|
90
|
+
"unknown kind of complexContent: #{type.compoundtype}")
|
91
|
+
end
|
92
|
+
}.compact.join("\n")
|
93
|
+
end
|
94
|
+
|
95
|
+
def dump_simpletypedef(qname, simpletype)
|
96
|
+
if !simpletype.restriction or simpletype.restriction.enumeration.empty?
|
97
|
+
return nil
|
98
|
+
end
|
99
|
+
c = XSD::CodeGen::ModuleDef.new(create_class_name(qname))
|
100
|
+
c.comment = "#{qname}"
|
101
|
+
const = {}
|
102
|
+
simpletype.restriction.enumeration.each do |value|
|
103
|
+
constname = safeconstname(value)
|
104
|
+
const[constname] ||= 0
|
105
|
+
if (const[constname] += 1) > 1
|
106
|
+
constname += "_#{const[constname]}"
|
107
|
+
end
|
108
|
+
c.def_const(constname, ndq(value))
|
109
|
+
end
|
110
|
+
c.dump
|
111
|
+
end
|
112
|
+
|
113
|
+
def dump_simpleclassdef(type_or_element)
|
114
|
+
qname = type_or_element.name
|
115
|
+
base = create_class_name(type_or_element.simplecontent.base)
|
116
|
+
c = XSD::CodeGen::ClassDef.new(create_class_name(qname), base)
|
117
|
+
c.comment = "#{qname}"
|
118
|
+
c.dump
|
119
|
+
end
|
120
|
+
|
121
|
+
def dump_classdef(qname, typedef, qualified = false)
|
122
|
+
if @faulttypes and @faulttypes.index(qname)
|
123
|
+
c = XSD::CodeGen::ClassDef.new(create_class_name(qname),
|
124
|
+
'::StandardError')
|
125
|
+
else
|
126
|
+
c = XSD::CodeGen::ClassDef.new(create_class_name(qname))
|
127
|
+
end
|
128
|
+
c.comment = "#{qname}"
|
129
|
+
c.def_classvar('schema_type', ndq(qname.name))
|
130
|
+
c.def_classvar('schema_ns', ndq(qname.namespace))
|
131
|
+
c.def_classvar('schema_qualified', dq('true')) if qualified
|
132
|
+
schema_element = []
|
133
|
+
init_lines = ''
|
134
|
+
params = []
|
135
|
+
typedef.each_element do |element|
|
136
|
+
if element.type == XSD::AnyTypeName
|
137
|
+
type = nil
|
138
|
+
elsif klass = element_basetype(element)
|
139
|
+
type = klass.name
|
140
|
+
elsif element.type
|
141
|
+
type = create_class_name(element.type)
|
142
|
+
else
|
143
|
+
type = nil # means anyType.
|
144
|
+
# do we define a class for local complexType from it's name?
|
145
|
+
# type = create_class_name(element.name)
|
146
|
+
# <element>
|
147
|
+
# <complexType>
|
148
|
+
# <seq...>
|
149
|
+
# </complexType>
|
150
|
+
# </element>
|
151
|
+
end
|
152
|
+
name = name_element(element).name
|
153
|
+
attrname = safemethodname?(name) ? name : safemethodname(name)
|
154
|
+
varname = safevarname(name)
|
155
|
+
c.def_attr(attrname, true, varname)
|
156
|
+
init_lines << "@#{varname} = #{varname}\n"
|
157
|
+
if element.map_as_array?
|
158
|
+
params << "#{varname} = []"
|
159
|
+
type << '[]' if type
|
160
|
+
else
|
161
|
+
params << "#{varname} = nil"
|
162
|
+
end
|
163
|
+
# nil means @@schema_ns + varname
|
164
|
+
eleqname =
|
165
|
+
(varname == name && element.name.namespace == qname.namespace) ?
|
166
|
+
nil : element.name
|
167
|
+
schema_element << [varname, eleqname, type]
|
168
|
+
end
|
169
|
+
unless typedef.attributes.empty?
|
170
|
+
define_attribute(c, typedef.attributes)
|
171
|
+
init_lines << "@__xmlattr = {}\n"
|
172
|
+
end
|
173
|
+
c.def_classvar('schema_element',
|
174
|
+
'[' +
|
175
|
+
schema_element.collect { |varname, name, type|
|
176
|
+
'[' +
|
177
|
+
(
|
178
|
+
if name
|
179
|
+
varname.dump + ', [' + ndq(type) + ', ' + dqname(name) + ']'
|
180
|
+
else
|
181
|
+
varname.dump + ', ' + ndq(type)
|
182
|
+
end
|
183
|
+
) +
|
184
|
+
']'
|
185
|
+
}.join(', ') +
|
186
|
+
']'
|
187
|
+
)
|
188
|
+
c.def_method('initialize', *params) do
|
189
|
+
init_lines
|
190
|
+
end
|
191
|
+
c.dump
|
192
|
+
end
|
193
|
+
|
194
|
+
def element_basetype(ele)
|
195
|
+
if klass = basetype_class(ele.type)
|
196
|
+
klass
|
197
|
+
elsif ele.local_simpletype
|
198
|
+
basetype_class(ele.local_simpletype.base)
|
199
|
+
else
|
200
|
+
nil
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
def attribute_basetype(attr)
|
205
|
+
if klass = basetype_class(attr.type)
|
206
|
+
klass
|
207
|
+
elsif attr.local_simpletype
|
208
|
+
basetype_class(attr.local_simpletype.base)
|
209
|
+
else
|
210
|
+
nil
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
def basetype_class(type)
|
215
|
+
return nil if type.nil?
|
216
|
+
if simpletype = @simpletypes[type]
|
217
|
+
basetype_mapped_class(simpletype.base)
|
218
|
+
else
|
219
|
+
basetype_mapped_class(type)
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
def define_attribute(c, attributes)
|
224
|
+
schema_attribute = []
|
225
|
+
attributes.each do |attribute|
|
226
|
+
name = name_attribute(attribute)
|
227
|
+
if klass = attribute_basetype(attribute)
|
228
|
+
type = klass.name
|
229
|
+
else
|
230
|
+
type = nil
|
231
|
+
end
|
232
|
+
methodname = safemethodname('xmlattr_' + name.name)
|
233
|
+
c.def_method(methodname) do <<-__EOD__
|
234
|
+
(@__xmlattr ||= {})[#{dqname(name)}]
|
235
|
+
__EOD__
|
236
|
+
end
|
237
|
+
c.def_method(methodname + '=', 'value') do <<-__EOD__
|
238
|
+
(@__xmlattr ||= {})[#{dqname(name)}] = value
|
239
|
+
__EOD__
|
240
|
+
end
|
241
|
+
schema_attribute << [name, type]
|
242
|
+
end
|
243
|
+
c.def_classvar('schema_attribute',
|
244
|
+
'{' +
|
245
|
+
schema_attribute.collect { |name, type|
|
246
|
+
dqname(name) + ' => ' + ndq(type)
|
247
|
+
}.join(', ') +
|
248
|
+
'}'
|
249
|
+
)
|
250
|
+
end
|
251
|
+
|
252
|
+
def name_element(element)
|
253
|
+
return element.name if element.name
|
254
|
+
return element.ref if element.ref
|
255
|
+
raise RuntimeError.new("cannot define name of #{element}")
|
256
|
+
end
|
257
|
+
|
258
|
+
def name_attribute(attribute)
|
259
|
+
return attribute.name if attribute.name
|
260
|
+
return attribute.ref if attribute.ref
|
261
|
+
raise RuntimeError.new("cannot define name of #{attribute}")
|
262
|
+
end
|
263
|
+
|
264
|
+
DEFAULT_ITEM_NAME = XSD::QName.new(nil, 'item')
|
265
|
+
|
266
|
+
def dump_arraydef(complextype)
|
267
|
+
qname = complextype.name
|
268
|
+
c = XSD::CodeGen::ClassDef.new(create_class_name(qname), '::Array')
|
269
|
+
c.comment = "#{qname}"
|
270
|
+
child_type = complextype.child_type
|
271
|
+
c.def_classvar('schema_type', ndq(child_type.name))
|
272
|
+
c.def_classvar('schema_ns', ndq(child_type.namespace))
|
273
|
+
child_element = complextype.find_aryelement
|
274
|
+
schema_element = []
|
275
|
+
if child_type == XSD::AnyTypeName
|
276
|
+
type = nil
|
277
|
+
elsif child_element and (klass = element_basetype(child_element))
|
278
|
+
type = klass.name
|
279
|
+
elsif child_type
|
280
|
+
type = create_class_name(child_type)
|
281
|
+
else
|
282
|
+
type = nil
|
283
|
+
end
|
284
|
+
if child_element
|
285
|
+
if child_element.map_as_array?
|
286
|
+
type << '[]' if type
|
287
|
+
end
|
288
|
+
child_element_name = child_element.name
|
289
|
+
else
|
290
|
+
child_element_name = DEFAULT_ITEM_NAME
|
291
|
+
end
|
292
|
+
schema_element << [child_element_name.name, child_element_name, type]
|
293
|
+
c.def_classvar('schema_element',
|
294
|
+
'[' +
|
295
|
+
schema_element.collect { |varname, name, type|
|
296
|
+
'[' +
|
297
|
+
(
|
298
|
+
if name
|
299
|
+
varname.dump + ', [' + ndq(type) + ', ' + dqname(name) + ']'
|
300
|
+
else
|
301
|
+
varname.dump + ', ' + ndq(type)
|
302
|
+
end
|
303
|
+
) +
|
304
|
+
']'
|
305
|
+
}.join(', ') +
|
306
|
+
']'
|
307
|
+
)
|
308
|
+
c.dump
|
309
|
+
end
|
310
|
+
end
|
311
|
+
|
312
|
+
|
313
|
+
end
|
314
|
+
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
# WSDL4R - Creating class code support from WSDL.
|
2
|
+
# Copyright (C) 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
3
|
+
|
4
|
+
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
5
|
+
# redistribute it and/or modify it under the same terms of Ruby's license;
|
6
|
+
# either the dual license version in 2003, or any later version.
|
7
|
+
|
8
|
+
|
9
|
+
require 'action_web_service/wsdl/info'
|
10
|
+
require 'action_web_service/soap/mapping'
|
11
|
+
require 'action_web_service/soap/mapping/typeMap'
|
12
|
+
require 'action_web_service/xsd/codegen/gensupport'
|
13
|
+
|
14
|
+
|
15
|
+
module WSDL
|
16
|
+
module SOAP
|
17
|
+
|
18
|
+
|
19
|
+
module ClassDefCreatorSupport
|
20
|
+
include XSD::CodeGen::GenSupport
|
21
|
+
|
22
|
+
def create_class_name(qname)
|
23
|
+
if klass = basetype_mapped_class(qname)
|
24
|
+
::SOAP::Mapping::DefaultRegistry.find_mapped_obj_class(klass).name
|
25
|
+
else
|
26
|
+
safeconstname(qname.name)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def basetype_mapped_class(name)
|
31
|
+
::SOAP::TypeMap[name]
|
32
|
+
end
|
33
|
+
|
34
|
+
def dump_method_signature(operation)
|
35
|
+
name = operation.name.name
|
36
|
+
input = operation.input
|
37
|
+
output = operation.output
|
38
|
+
fault = operation.fault
|
39
|
+
signature = "#{ name }#{ dump_inputparam(input) }"
|
40
|
+
str = <<__EOD__
|
41
|
+
# SYNOPSIS
|
42
|
+
# #{name}#{dump_inputparam(input)}
|
43
|
+
#
|
44
|
+
# ARGS
|
45
|
+
#{dump_inout_type(input).chomp}
|
46
|
+
#
|
47
|
+
# RETURNS
|
48
|
+
#{dump_inout_type(output).chomp}
|
49
|
+
#
|
50
|
+
__EOD__
|
51
|
+
unless fault.empty?
|
52
|
+
faultstr = (fault.collect { |f| dump_inout_type(f).chomp }).join(', ')
|
53
|
+
str <<<<__EOD__
|
54
|
+
# RAISES
|
55
|
+
# #{faultstr}
|
56
|
+
#
|
57
|
+
__EOD__
|
58
|
+
end
|
59
|
+
str
|
60
|
+
end
|
61
|
+
|
62
|
+
def dq(ele)
|
63
|
+
ele.dump
|
64
|
+
end
|
65
|
+
|
66
|
+
def ndq(ele)
|
67
|
+
ele.nil? ? 'nil' : dq(ele)
|
68
|
+
end
|
69
|
+
|
70
|
+
def sym(ele)
|
71
|
+
':' + ele
|
72
|
+
end
|
73
|
+
|
74
|
+
def dqname(qname)
|
75
|
+
qname.dump
|
76
|
+
end
|
77
|
+
|
78
|
+
private
|
79
|
+
|
80
|
+
def dump_inout_type(param)
|
81
|
+
if param
|
82
|
+
message = param.find_message
|
83
|
+
params = ""
|
84
|
+
message.parts.each do |part|
|
85
|
+
name = safevarname(part.name)
|
86
|
+
if part.type
|
87
|
+
typename = safeconstname(part.type.name)
|
88
|
+
params << add_at("# #{name}", "#{typename} - #{part.type}\n", 20)
|
89
|
+
elsif part.element
|
90
|
+
typename = safeconstname(part.element.name)
|
91
|
+
params << add_at("# #{name}", "#{typename} - #{part.element}\n", 20)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
unless params.empty?
|
95
|
+
return params
|
96
|
+
end
|
97
|
+
end
|
98
|
+
"# N/A\n"
|
99
|
+
end
|
100
|
+
|
101
|
+
def dump_inputparam(input)
|
102
|
+
message = input.find_message
|
103
|
+
params = ""
|
104
|
+
message.parts.each do |part|
|
105
|
+
params << ", " unless params.empty?
|
106
|
+
params << safevarname(part.name)
|
107
|
+
end
|
108
|
+
if params.empty?
|
109
|
+
""
|
110
|
+
else
|
111
|
+
"(#{ params })"
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def add_at(base, str, pos)
|
116
|
+
if base.size >= pos
|
117
|
+
base + ' ' + str
|
118
|
+
else
|
119
|
+
base + ' ' * (pos - base.size) + str
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
|
125
|
+
end
|
126
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# WSDL4R - Creating client skelton code from WSDL.
|
2
|
+
# Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
3
|
+
|
4
|
+
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
5
|
+
# redistribute it and/or modify it under the same terms of Ruby's license;
|
6
|
+
# either the dual license version in 2003, or any later version.
|
7
|
+
|
8
|
+
|
9
|
+
require 'action_web_service/wsdl/info'
|
10
|
+
require 'action_web_service/wsdl/soap/classDefCreatorSupport'
|
11
|
+
|
12
|
+
|
13
|
+
module WSDL
|
14
|
+
module SOAP
|
15
|
+
|
16
|
+
|
17
|
+
class ClientSkeltonCreator
|
18
|
+
include ClassDefCreatorSupport
|
19
|
+
|
20
|
+
attr_reader :definitions
|
21
|
+
|
22
|
+
def initialize(definitions)
|
23
|
+
@definitions = definitions
|
24
|
+
end
|
25
|
+
|
26
|
+
def dump(service_name)
|
27
|
+
result = ""
|
28
|
+
@definitions.service(service_name).ports.each do |port|
|
29
|
+
result << dump_porttype(port.porttype.name)
|
30
|
+
result << "\n"
|
31
|
+
end
|
32
|
+
result
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def dump_porttype(name)
|
38
|
+
drv_name = create_class_name(name)
|
39
|
+
|
40
|
+
result = ""
|
41
|
+
result << <<__EOD__
|
42
|
+
endpoint_url = ARGV.shift
|
43
|
+
obj = #{ drv_name }.new(endpoint_url)
|
44
|
+
|
45
|
+
# run ruby with -d to see SOAP wiredumps.
|
46
|
+
obj.wiredump_dev = STDERR if $DEBUG
|
47
|
+
|
48
|
+
__EOD__
|
49
|
+
@definitions.porttype(name).operations.each do |operation|
|
50
|
+
result << dump_method_signature(operation)
|
51
|
+
result << dump_input_init(operation.input) << "\n"
|
52
|
+
result << dump_operation(operation) << "\n\n"
|
53
|
+
end
|
54
|
+
result
|
55
|
+
end
|
56
|
+
|
57
|
+
def dump_operation(operation)
|
58
|
+
name = operation.name
|
59
|
+
input = operation.input
|
60
|
+
"puts obj.#{ safemethodname(name.name) }#{ dump_inputparam(input) }"
|
61
|
+
end
|
62
|
+
|
63
|
+
def dump_input_init(input)
|
64
|
+
result = input.find_message.parts.collect { |part|
|
65
|
+
safevarname(part.name)
|
66
|
+
}.join(" = ")
|
67
|
+
if result.empty?
|
68
|
+
""
|
69
|
+
else
|
70
|
+
result << " = nil"
|
71
|
+
end
|
72
|
+
result
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
end
|
78
|
+
end
|