railsware-soap4r 1.5.8.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README +5 -0
- data/TODO +0 -0
- data/bin/wsdl2ruby.rb +137 -0
- data/bin/xsd2ruby.rb +90 -0
- data/lib/soap/XMLSchemaDatatypes.rb +9 -0
- data/lib/soap/XMLSchemaDatatypes1999.rb +10 -0
- data/lib/soap/attachment.rb +108 -0
- data/lib/soap/baseData.rb +1092 -0
- data/lib/soap/cgistub.rb +9 -0
- data/lib/soap/charset.rb +9 -0
- data/lib/soap/compat.rb +182 -0
- data/lib/soap/driver.rb +9 -0
- data/lib/soap/element.rb +277 -0
- data/lib/soap/encodingstyle/aspDotNetHandler.rb +207 -0
- data/lib/soap/encodingstyle/handler.rb +120 -0
- data/lib/soap/encodingstyle/literalHandler.rb +192 -0
- data/lib/soap/encodingstyle/soapHandler.rb +559 -0
- data/lib/soap/filter.rb +13 -0
- data/lib/soap/filter/filterchain.rb +51 -0
- data/lib/soap/filter/handler.rb +31 -0
- data/lib/soap/filter/streamhandler.rb +29 -0
- data/lib/soap/generator.rb +304 -0
- data/lib/soap/header/handler.rb +61 -0
- data/lib/soap/header/handlerset.rb +70 -0
- data/lib/soap/header/mappinghandler.rb +47 -0
- data/lib/soap/header/simplehandler.rb +44 -0
- data/lib/soap/httpconfigloader.rb +139 -0
- data/lib/soap/mapping.rb +12 -0
- data/lib/soap/mapping/encodedregistry.rb +548 -0
- data/lib/soap/mapping/factory.rb +388 -0
- data/lib/soap/mapping/literalregistry.rb +388 -0
- data/lib/soap/mapping/mapping.rb +609 -0
- data/lib/soap/mapping/registry.rb +295 -0
- data/lib/soap/mapping/rubytypeFactory.rb +478 -0
- data/lib/soap/mapping/schemadefinition.rb +170 -0
- data/lib/soap/mapping/typeMap.rb +106 -0
- data/lib/soap/mapping/wsdlencodedregistry.rb +211 -0
- data/lib/soap/mapping/wsdlliteralregistry.rb +243 -0
- data/lib/soap/mappingRegistry.rb +9 -0
- data/lib/soap/marshal.rb +59 -0
- data/lib/soap/mimemessage.rb +241 -0
- data/lib/soap/namespace.rb +9 -0
- data/lib/soap/nestedexception.rb +42 -0
- data/lib/soap/netHttpClient.rb +241 -0
- data/lib/soap/ns.rb +34 -0
- data/lib/soap/parser.rb +252 -0
- data/lib/soap/processor.rb +66 -0
- data/lib/soap/property.rb +333 -0
- data/lib/soap/proxy.rb +14 -0
- data/lib/soap/qname.rb +9 -0
- data/lib/soap/rpc/cgistub.rb +247 -0
- data/lib/soap/rpc/driver.rb +247 -0
- data/lib/soap/rpc/element.rb +369 -0
- data/lib/soap/rpc/httpserver.rb +169 -0
- data/lib/soap/rpc/proxy.rb +576 -0
- data/lib/soap/rpc/router.rb +669 -0
- data/lib/soap/rpc/rpc.rb +25 -0
- data/lib/soap/rpc/soaplet.rb +210 -0
- data/lib/soap/rpc/standaloneServer.rb +43 -0
- data/lib/soap/rpcRouter.rb +9 -0
- data/lib/soap/rpcUtils.rb +9 -0
- data/lib/soap/server.rb +9 -0
- data/lib/soap/soap.rb +151 -0
- data/lib/soap/standaloneServer.rb +9 -0
- data/lib/soap/streamHandler.rb +302 -0
- data/lib/soap/wsdlDriver.rb +597 -0
- data/lib/tags +5690 -0
- data/lib/wsdl/binding.rb +65 -0
- data/lib/wsdl/data.rb +64 -0
- data/lib/wsdl/definitions.rb +236 -0
- data/lib/wsdl/documentation.rb +32 -0
- data/lib/wsdl/import.rb +80 -0
- data/lib/wsdl/importer.rb +38 -0
- data/lib/wsdl/info.rb +50 -0
- data/lib/wsdl/message.rb +54 -0
- data/lib/wsdl/operation.rb +178 -0
- data/lib/wsdl/operationBinding.rb +130 -0
- data/lib/wsdl/param.rb +93 -0
- data/lib/wsdl/parser.rb +164 -0
- data/lib/wsdl/part.rb +52 -0
- data/lib/wsdl/port.rb +84 -0
- data/lib/wsdl/portType.rb +75 -0
- data/lib/wsdl/service.rb +61 -0
- data/lib/wsdl/soap/address.rb +40 -0
- data/lib/wsdl/soap/binding.rb +49 -0
- data/lib/wsdl/soap/body.rb +58 -0
- data/lib/wsdl/soap/cgiStubCreator.rb +93 -0
- data/lib/wsdl/soap/classDefCreator.rb +433 -0
- data/lib/wsdl/soap/classDefCreatorSupport.rb +230 -0
- data/lib/wsdl/soap/classNameCreator.rb +54 -0
- data/lib/wsdl/soap/clientSkeltonCreator.rb +95 -0
- data/lib/wsdl/soap/complexType.rb +172 -0
- data/lib/wsdl/soap/data.rb +42 -0
- data/lib/wsdl/soap/definitions.rb +200 -0
- data/lib/wsdl/soap/driverCreator.rb +118 -0
- data/lib/wsdl/soap/element.rb +33 -0
- data/lib/wsdl/soap/encodedMappingRegistryCreator.rb +73 -0
- data/lib/wsdl/soap/fault.rb +56 -0
- data/lib/wsdl/soap/header.rb +86 -0
- data/lib/wsdl/soap/headerfault.rb +56 -0
- data/lib/wsdl/soap/literalMappingRegistryCreator.rb +115 -0
- data/lib/wsdl/soap/mappingRegistryCreator.rb +58 -0
- data/lib/wsdl/soap/mappingRegistryCreatorSupport.rb +376 -0
- data/lib/wsdl/soap/methodDefCreator.rb +263 -0
- data/lib/wsdl/soap/operation.rb +122 -0
- data/lib/wsdl/soap/servantSkeltonCreator.rb +80 -0
- data/lib/wsdl/soap/servletStubCreator.rb +107 -0
- data/lib/wsdl/soap/standaloneServerStubCreator.rb +103 -0
- data/lib/wsdl/soap/wsdl2ruby.rb +217 -0
- data/lib/wsdl/types.rb +44 -0
- data/lib/wsdl/wsdl.rb +24 -0
- data/lib/wsdl/xmlSchema/all.rb +24 -0
- data/lib/wsdl/xmlSchema/annotation.rb +34 -0
- data/lib/wsdl/xmlSchema/any.rb +61 -0
- data/lib/wsdl/xmlSchema/anyAttribute.rb +48 -0
- data/lib/wsdl/xmlSchema/attribute.rb +123 -0
- data/lib/wsdl/xmlSchema/attributeGroup.rb +86 -0
- data/lib/wsdl/xmlSchema/choice.rb +58 -0
- data/lib/wsdl/xmlSchema/complexContent.rb +97 -0
- data/lib/wsdl/xmlSchema/complexExtension.rb +119 -0
- data/lib/wsdl/xmlSchema/complexRestriction.rb +104 -0
- data/lib/wsdl/xmlSchema/complexType.rb +193 -0
- data/lib/wsdl/xmlSchema/content.rb +95 -0
- data/lib/wsdl/xmlSchema/data.rb +116 -0
- data/lib/wsdl/xmlSchema/element.rb +173 -0
- data/lib/wsdl/xmlSchema/enumeration.rb +36 -0
- data/lib/wsdl/xmlSchema/fractiondigits.rb +37 -0
- data/lib/wsdl/xmlSchema/group.rb +118 -0
- data/lib/wsdl/xmlSchema/import.rb +53 -0
- data/lib/wsdl/xmlSchema/importHandler.rb +45 -0
- data/lib/wsdl/xmlSchema/importer.rb +102 -0
- data/lib/wsdl/xmlSchema/include.rb +48 -0
- data/lib/wsdl/xmlSchema/length.rb +37 -0
- data/lib/wsdl/xmlSchema/list.rb +48 -0
- data/lib/wsdl/xmlSchema/maxexclusive.rb +37 -0
- data/lib/wsdl/xmlSchema/maxinclusive.rb +37 -0
- data/lib/wsdl/xmlSchema/maxlength.rb +37 -0
- data/lib/wsdl/xmlSchema/minexclusive.rb +37 -0
- data/lib/wsdl/xmlSchema/mininclusive.rb +37 -0
- data/lib/wsdl/xmlSchema/minlength.rb +37 -0
- data/lib/wsdl/xmlSchema/parser.rb +167 -0
- data/lib/wsdl/xmlSchema/pattern.rb +36 -0
- data/lib/wsdl/xmlSchema/schema.rb +178 -0
- data/lib/wsdl/xmlSchema/sequence.rb +54 -0
- data/lib/wsdl/xmlSchema/simpleContent.rb +69 -0
- data/lib/wsdl/xmlSchema/simpleExtension.rb +62 -0
- data/lib/wsdl/xmlSchema/simpleRestriction.rb +132 -0
- data/lib/wsdl/xmlSchema/simpleType.rb +87 -0
- data/lib/wsdl/xmlSchema/totaldigits.rb +37 -0
- data/lib/wsdl/xmlSchema/union.rb +35 -0
- data/lib/wsdl/xmlSchema/unique.rb +34 -0
- data/lib/wsdl/xmlSchema/whitespace.rb +37 -0
- data/lib/wsdl/xmlSchema/xsd2ruby.rb +174 -0
- data/lib/xsd/charset.rb +189 -0
- data/lib/xsd/codegen.rb +12 -0
- data/lib/xsd/codegen/classdef.rb +208 -0
- data/lib/xsd/codegen/commentdef.rb +34 -0
- data/lib/xsd/codegen/gensupport.rb +273 -0
- data/lib/xsd/codegen/methoddef.rb +70 -0
- data/lib/xsd/codegen/moduledef.rb +208 -0
- data/lib/xsd/datatypes.rb +1466 -0
- data/lib/xsd/datatypes1999.rb +20 -0
- data/lib/xsd/iconvcharset.rb +33 -0
- data/lib/xsd/mapping.rb +67 -0
- data/lib/xsd/namedelements.rb +132 -0
- data/lib/xsd/ns.rb +182 -0
- data/lib/xsd/qname.rb +79 -0
- data/lib/xsd/xmlparser.rb +75 -0
- data/lib/xsd/xmlparser/parser.rb +100 -0
- data/lib/xsd/xmlparser/rexmlparser.rb +58 -0
- data/lib/xsd/xmlparser/xmlparser.rb +50 -0
- data/lib/xsd/xmlparser/xmlscanner.rb +149 -0
- data/soap4r.gemspec +218 -0
- metadata +233 -0
@@ -0,0 +1,263 @@
|
|
1
|
+
# WSDL4R - Creating driver code from WSDL.
|
2
|
+
# Copyright (C) 2000-2007 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 'wsdl/info'
|
10
|
+
require 'wsdl/soap/classDefCreatorSupport'
|
11
|
+
require 'soap/rpc/element'
|
12
|
+
|
13
|
+
|
14
|
+
module WSDL
|
15
|
+
module SOAP
|
16
|
+
|
17
|
+
|
18
|
+
class MethodDefCreator
|
19
|
+
include ClassDefCreatorSupport
|
20
|
+
|
21
|
+
attr_reader :definitions
|
22
|
+
|
23
|
+
def initialize(definitions, name_creator, modulepath, defined_const)
|
24
|
+
@definitions = definitions
|
25
|
+
@name_creator = name_creator
|
26
|
+
@modulepath = modulepath
|
27
|
+
@simpletypes = @definitions.collect_simpletypes
|
28
|
+
@complextypes = @definitions.collect_complextypes
|
29
|
+
@elements = @definitions.collect_elements
|
30
|
+
@types = []
|
31
|
+
@encoded = false
|
32
|
+
@literal = false
|
33
|
+
@defined_const = defined_const
|
34
|
+
end
|
35
|
+
|
36
|
+
def dump(name)
|
37
|
+
@types.clear
|
38
|
+
@encoded = false
|
39
|
+
@literal = false
|
40
|
+
methoddef = ""
|
41
|
+
porttype = @definitions.porttype(name)
|
42
|
+
binding = porttype.find_binding
|
43
|
+
if binding
|
44
|
+
binding.operations.each do |op_bind|
|
45
|
+
next unless op_bind # no binding is defined
|
46
|
+
next unless op_bind.soapoperation # not a SOAP operation binding
|
47
|
+
op = op_bind.find_operation
|
48
|
+
methoddef << ",\n" unless methoddef.empty?
|
49
|
+
methoddef << dump_method(op, op_bind).chomp
|
50
|
+
end
|
51
|
+
end
|
52
|
+
result = {
|
53
|
+
:methoddef => methoddef,
|
54
|
+
:types => @types,
|
55
|
+
:encoded => @encoded,
|
56
|
+
:literal => @literal
|
57
|
+
}
|
58
|
+
result
|
59
|
+
end
|
60
|
+
|
61
|
+
def collect_rpcparameter(operation)
|
62
|
+
result = operation.inputparts.collect { |part|
|
63
|
+
collect_type(part.type)
|
64
|
+
param_set(::SOAP::RPC::SOAPMethod::IN, part.name, rpcdefinedtype(part))
|
65
|
+
}
|
66
|
+
outparts = operation.outputparts
|
67
|
+
if outparts.size > 0
|
68
|
+
retval = outparts[0]
|
69
|
+
collect_type(retval.type)
|
70
|
+
result << param_set(::SOAP::RPC::SOAPMethod::RETVAL, retval.name,
|
71
|
+
rpcdefinedtype(retval))
|
72
|
+
cdr(outparts).each { |part|
|
73
|
+
collect_type(part.type)
|
74
|
+
result << param_set(::SOAP::RPC::SOAPMethod::OUT, part.name,
|
75
|
+
rpcdefinedtype(part))
|
76
|
+
}
|
77
|
+
end
|
78
|
+
result
|
79
|
+
end
|
80
|
+
|
81
|
+
def collect_documentparameter(operation)
|
82
|
+
param = []
|
83
|
+
operation.inputparts.each do |input|
|
84
|
+
param << param_set(::SOAP::RPC::SOAPMethod::IN, input.name,
|
85
|
+
documentdefinedtype(input))
|
86
|
+
end
|
87
|
+
operation.outputparts.each do |output|
|
88
|
+
param << param_set(::SOAP::RPC::SOAPMethod::OUT, output.name,
|
89
|
+
documentdefinedtype(output))
|
90
|
+
end
|
91
|
+
param
|
92
|
+
end
|
93
|
+
|
94
|
+
private
|
95
|
+
|
96
|
+
def dump_method(operation, binding)
|
97
|
+
op_faults = {}
|
98
|
+
binding.fault.each do |fault|
|
99
|
+
op_fault = {}
|
100
|
+
soapfault = fault.soapfault
|
101
|
+
next if soapfault.nil?
|
102
|
+
faultclass = mapped_class_name(fault.name, @modulepath)
|
103
|
+
op_fault[:ns] = fault.name.namespace
|
104
|
+
op_fault[:name] = fault.name.name
|
105
|
+
op_fault[:namespace] = soapfault.namespace
|
106
|
+
op_fault[:use] = soapfault.use || "literal"
|
107
|
+
op_fault[:encodingstyle] = soapfault.encodingstyle || "document"
|
108
|
+
op_faults[faultclass] = op_fault
|
109
|
+
end
|
110
|
+
op_faults_str = op_faults.inspect
|
111
|
+
|
112
|
+
name = safemethodname(operation.name)
|
113
|
+
name_as = operation.name
|
114
|
+
style = binding.soapoperation_style
|
115
|
+
inputuse = binding.soapbody_use_input
|
116
|
+
outputuse = binding.soapbody_use_output
|
117
|
+
if style == :rpc
|
118
|
+
qname = binding.soapoperation_name
|
119
|
+
paramstr = param2str(collect_rpcparameter(operation))
|
120
|
+
else
|
121
|
+
qname = nil
|
122
|
+
paramstr = param2str(collect_documentparameter(operation))
|
123
|
+
end
|
124
|
+
if paramstr.empty?
|
125
|
+
paramstr = '[]'
|
126
|
+
else
|
127
|
+
paramstr = "[ " << paramstr.split(/\r?\n/).join("\n ") << " ]"
|
128
|
+
end
|
129
|
+
definitions = <<__EOD__
|
130
|
+
#{ndq(binding.soapaction)},
|
131
|
+
#{dq(name)},
|
132
|
+
#{paramstr},
|
133
|
+
{ :request_style => #{nsym(style)}, :request_use => #{nsym(inputuse)},
|
134
|
+
:response_style => #{nsym(style)}, :response_use => #{nsym(outputuse)},
|
135
|
+
:faults => #{op_faults_str} }
|
136
|
+
__EOD__
|
137
|
+
if inputuse == :encoded or outputuse == :encoded
|
138
|
+
@encoded = true
|
139
|
+
end
|
140
|
+
if inputuse == :literal or outputuse == :literal
|
141
|
+
@literal = true
|
142
|
+
end
|
143
|
+
if style == :rpc
|
144
|
+
assign_const(qname.namespace, 'Ns')
|
145
|
+
return <<__EOD__
|
146
|
+
[ #{dqname(qname)},
|
147
|
+
#{definitions}]
|
148
|
+
__EOD__
|
149
|
+
else
|
150
|
+
return <<__EOD__
|
151
|
+
[ #{definitions}]
|
152
|
+
__EOD__
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
def rpcdefinedtype(part)
|
157
|
+
if mapped = basetype_mapped_class(part.type)
|
158
|
+
['::' + mapped.name]
|
159
|
+
elsif definedtype = @simpletypes[part.type]
|
160
|
+
[nil, definedtype.name.namespace, definedtype.name.name]
|
161
|
+
elsif definedtype = @elements[part.element]
|
162
|
+
[nil, part.element.namespace, part.element.name]
|
163
|
+
elsif definedtype = @complextypes[part.type]
|
164
|
+
case definedtype.compoundtype
|
165
|
+
when :TYPE_STRUCT, :TYPE_EMPTY, :TYPE_ARRAY, :TYPE_SIMPLE
|
166
|
+
type = mapped_class_name(part.type, @modulepath)
|
167
|
+
[type, part.type.namespace, part.type.name]
|
168
|
+
when :TYPE_MAP
|
169
|
+
[Hash.name, part.type.namespace, part.type.name]
|
170
|
+
else
|
171
|
+
raise NotImplementedError.new("must not reach here: #{definedtype.compoundtype}")
|
172
|
+
end
|
173
|
+
elsif part.type == XSD::AnyTypeName
|
174
|
+
[nil]
|
175
|
+
else
|
176
|
+
raise RuntimeError.new("part: #{part.name} cannot be resolved")
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
def documentdefinedtype(part)
|
181
|
+
if mapped = basetype_mapped_class(part.type)
|
182
|
+
['::' + mapped.name, nil, part.name]
|
183
|
+
elsif definedtype = @simpletypes[part.type]
|
184
|
+
if definedtype.base
|
185
|
+
['::' + basetype_mapped_class(definedtype.base).name, nil, part.name]
|
186
|
+
else
|
187
|
+
raise RuntimeError.new("unsupported simpleType: #{definedtype}")
|
188
|
+
end
|
189
|
+
elsif definedtype = @elements[part.element]
|
190
|
+
['::SOAP::SOAPElement', part.element.namespace, part.element.name]
|
191
|
+
elsif definedtype = @complextypes[part.type]
|
192
|
+
['::SOAP::SOAPElement', part.type.namespace, part.type.name]
|
193
|
+
else
|
194
|
+
raise RuntimeError.new("part: #{part.name} cannot be resolved")
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
def param_set(io_type, name, type, ele = nil)
|
199
|
+
[io_type, name, type, ele]
|
200
|
+
end
|
201
|
+
|
202
|
+
def collect_type(type)
|
203
|
+
# ignore inline type definition.
|
204
|
+
return if type.nil?
|
205
|
+
return if @types.include?(type)
|
206
|
+
@types << type
|
207
|
+
return unless @complextypes[type]
|
208
|
+
collect_elements_type(@complextypes[type].elements)
|
209
|
+
end
|
210
|
+
|
211
|
+
def collect_elements_type(elements)
|
212
|
+
elements.each do |element|
|
213
|
+
case element
|
214
|
+
when WSDL::XMLSchema::Any
|
215
|
+
# nothing to do
|
216
|
+
when WSDL::XMLSchema::Element
|
217
|
+
collect_type(element.type)
|
218
|
+
when WSDL::XMLSchema::Sequence, WSDL::XMLSchema::Choice
|
219
|
+
collect_elements_type(element.elements)
|
220
|
+
else
|
221
|
+
raise RuntimeError.new("unknown type: #{element}")
|
222
|
+
end
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
def param2str(params)
|
227
|
+
params.collect { |param|
|
228
|
+
io, name, type, ele = param
|
229
|
+
unless ele.nil?
|
230
|
+
"[#{dq(io)}, #{dq(name)}, #{type2str(type)}, #{ele2str(ele)}]"
|
231
|
+
else
|
232
|
+
"[#{dq(io)}, #{dq(name)}, #{type2str(type)}]"
|
233
|
+
end
|
234
|
+
}.join(",\n")
|
235
|
+
end
|
236
|
+
|
237
|
+
def type2str(type)
|
238
|
+
if type.size == 1
|
239
|
+
"[#{ndq(type[0])}]"
|
240
|
+
else
|
241
|
+
"[#{ndq(type[0])}, #{ndq(type[1])}, #{dq(type[2])}]"
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
def ele2str(ele)
|
246
|
+
qualified = ele
|
247
|
+
if qualified
|
248
|
+
"true"
|
249
|
+
else
|
250
|
+
"false"
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
def cdr(ary)
|
255
|
+
result = ary.dup
|
256
|
+
result.shift
|
257
|
+
result
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
|
262
|
+
end
|
263
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
# WSDL4R - WSDL SOAP operation definition.
|
2
|
+
# Copyright (C) 2000-2007 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 'wsdl/info'
|
10
|
+
|
11
|
+
|
12
|
+
module WSDL
|
13
|
+
module SOAP
|
14
|
+
|
15
|
+
|
16
|
+
class Operation < Info
|
17
|
+
class OperationInfo
|
18
|
+
attr_reader :style
|
19
|
+
attr_reader :op_name
|
20
|
+
attr_reader :optype_name
|
21
|
+
attr_reader :encodingstyle
|
22
|
+
attr_reader :headerparts
|
23
|
+
attr_reader :bodyparts
|
24
|
+
attr_reader :faultpart
|
25
|
+
attr_reader :soapaction
|
26
|
+
|
27
|
+
def initialize(style, use, encodingstyle, op_name, optype_name,
|
28
|
+
headerparts, bodyparts, faultpart, soapaction)
|
29
|
+
@style = style
|
30
|
+
@use = use
|
31
|
+
@encodingstyle = encodingstyle
|
32
|
+
@op_name = op_name
|
33
|
+
@optype_name = optype_name
|
34
|
+
@headerparts = headerparts
|
35
|
+
@bodyparts = bodyparts
|
36
|
+
@faultpart = faultpart
|
37
|
+
@soapaction = soapaction
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
attr_reader :soapaction
|
42
|
+
attr_reader :style
|
43
|
+
|
44
|
+
def initialize
|
45
|
+
super
|
46
|
+
@soapaction = nil
|
47
|
+
@style = nil
|
48
|
+
end
|
49
|
+
|
50
|
+
def parse_element(element)
|
51
|
+
nil
|
52
|
+
end
|
53
|
+
|
54
|
+
def parse_attr(attr, value)
|
55
|
+
case attr
|
56
|
+
when StyleAttrName
|
57
|
+
if ["document", "rpc"].include?(value.source)
|
58
|
+
@style = value.source.intern
|
59
|
+
else
|
60
|
+
raise Parser::AttributeConstraintError.new(
|
61
|
+
"Unexpected value #{ value }.")
|
62
|
+
end
|
63
|
+
when SOAPActionAttrName
|
64
|
+
@soapaction = value.source
|
65
|
+
else
|
66
|
+
nil
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def input_info
|
71
|
+
name_info = parent.find_operation.input_info
|
72
|
+
param_info(name_info, parent.input)
|
73
|
+
end
|
74
|
+
|
75
|
+
def output_info
|
76
|
+
name_info = parent.find_operation.output_info
|
77
|
+
param_info(name_info, parent.output)
|
78
|
+
end
|
79
|
+
|
80
|
+
def operation_style
|
81
|
+
return @style if @style
|
82
|
+
if parent_binding.soapbinding
|
83
|
+
return parent_binding.soapbinding.style
|
84
|
+
end
|
85
|
+
nil
|
86
|
+
end
|
87
|
+
|
88
|
+
private
|
89
|
+
|
90
|
+
def parent_binding
|
91
|
+
parent.parent
|
92
|
+
end
|
93
|
+
|
94
|
+
def param_info(name_info, param)
|
95
|
+
op_style = operation_style()
|
96
|
+
op_use = param.soapbody_use
|
97
|
+
op_encodingstyle = param.soapbody_encodingstyle
|
98
|
+
op_name = name_info.op_name
|
99
|
+
optype_name = name_info.optype_name
|
100
|
+
soapheader = param.soapheader
|
101
|
+
headerparts = soapheader.collect { |item| item.find_part }
|
102
|
+
soapbody = param.soapbody
|
103
|
+
if soapbody.namespace
|
104
|
+
op_name = XSD::QName.new(soapbody.namespace, op_name.name)
|
105
|
+
end
|
106
|
+
if soapbody.parts
|
107
|
+
target = soapbody.parts.split(/\s+/)
|
108
|
+
bodyparts = name_info.parts.find_all { |part|
|
109
|
+
target.include?(part.name)
|
110
|
+
}
|
111
|
+
else
|
112
|
+
bodyparts = name_info.parts
|
113
|
+
end
|
114
|
+
faultpart = nil
|
115
|
+
OperationInfo.new(op_style, op_use, op_encodingstyle, op_name, optype_name,
|
116
|
+
headerparts, bodyparts, faultpart, parent.soapaction)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
|
121
|
+
end
|
122
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# WSDL4R - Creating servant skelton code from WSDL.
|
2
|
+
# Copyright (C) 2000-2007 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 'wsdl/info'
|
10
|
+
require 'wsdl/soap/classDefCreatorSupport'
|
11
|
+
require 'xsd/codegen'
|
12
|
+
|
13
|
+
|
14
|
+
module WSDL
|
15
|
+
module SOAP
|
16
|
+
|
17
|
+
|
18
|
+
class ServantSkeltonCreator
|
19
|
+
include ClassDefCreatorSupport
|
20
|
+
include XSD::CodeGen::GenSupport
|
21
|
+
|
22
|
+
attr_reader :definitions
|
23
|
+
|
24
|
+
def initialize(definitions, name_creator, modulepath = nil)
|
25
|
+
@definitions = definitions
|
26
|
+
@name_creator = name_creator
|
27
|
+
@modulepath = modulepath
|
28
|
+
end
|
29
|
+
|
30
|
+
def dump(porttype = nil)
|
31
|
+
result = ""
|
32
|
+
if @modulepath
|
33
|
+
result << "\n"
|
34
|
+
result << @modulepath.collect { |ele| "module #{ele}" }.join("; ")
|
35
|
+
result << "\n\n"
|
36
|
+
end
|
37
|
+
if porttype.nil?
|
38
|
+
@definitions.porttypes.each do |type|
|
39
|
+
result << dump_porttype(type.name)
|
40
|
+
result << "\n"
|
41
|
+
end
|
42
|
+
else
|
43
|
+
result << dump_porttype(porttype)
|
44
|
+
end
|
45
|
+
if @modulepath
|
46
|
+
result << "\n\n"
|
47
|
+
result << @modulepath.collect { |ele| "end" }.join("; ")
|
48
|
+
result << "\n"
|
49
|
+
end
|
50
|
+
result
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def dump_porttype(name)
|
56
|
+
class_name = mapped_class_basename(name, @modulepath)
|
57
|
+
c = XSD::CodeGen::ClassDef.new(class_name)
|
58
|
+
element_definitions = @definitions.collect_elements
|
59
|
+
operations = @definitions.porttype(name).operations
|
60
|
+
operations.each do |operation|
|
61
|
+
name = safemethodname(operation.name)
|
62
|
+
input = operation.input
|
63
|
+
params = input.find_message.parts.collect { |part|
|
64
|
+
safevarname(part.name)
|
65
|
+
}
|
66
|
+
m = XSD::CodeGen::MethodDef.new(name, params) do <<-EOD
|
67
|
+
p [#{params.join(", ")}]
|
68
|
+
raise NotImplementedError.new
|
69
|
+
EOD
|
70
|
+
end
|
71
|
+
m.comment = dump_method_signature(operation, element_definitions)
|
72
|
+
c.add_method(m)
|
73
|
+
end
|
74
|
+
c.dump
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
|
79
|
+
end
|
80
|
+
end
|