soap4r 1.5.6 → 1.5.7
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/wsdl2ruby.rb +1 -1
- data/bin/xsd2ruby.rb +12 -4
- data/lib/soap/baseData.rb +3 -1
- data/lib/soap/encodingstyle/literalHandler.rb +3 -2
- data/lib/soap/encodingstyle/soapHandler.rb +7 -4
- data/lib/soap/filter.rb +4 -1
- data/lib/soap/filter/filterchain.rb +1 -1
- data/lib/soap/filter/streamhandler.rb +29 -0
- data/lib/soap/generator.rb +6 -0
- data/lib/soap/httpconfigloader.rb +21 -6
- data/lib/soap/mapping/encodedregistry.rb +2 -1
- data/lib/soap/mapping/literalregistry.rb +31 -16
- data/lib/soap/mapping/registry.rb +5 -1
- data/lib/soap/mapping/rubytypeFactory.rb +3 -0
- data/lib/soap/mapping/wsdlliteralregistry.rb +3 -3
- data/lib/soap/netHttpClient.rb +6 -0
- data/lib/soap/rpc/router.rb +26 -17
- data/lib/soap/soap.rb +4 -4
- data/lib/soap/streamHandler.rb +61 -26
- data/lib/wsdl/soap/classDefCreator.rb +4 -2
- data/lib/wsdl/soap/literalMappingRegistryCreator.rb +7 -2
- data/lib/wsdl/soap/mappingRegistryCreator.rb +0 -2
- data/lib/wsdl/soap/mappingRegistryCreatorSupport.rb +2 -0
- data/lib/wsdl/soap/methodDefCreator.rb +6 -3
- data/lib/wsdl/xmlSchema/element.rb +4 -0
- data/lib/wsdl/xmlSchema/importer.rb +21 -9
- data/lib/wsdl/xmlSchema/xsd2ruby.rb +56 -3
- data/lib/xsd/mapping.rb +30 -13
- data/test/interopR2/client.log +5 -0
- data/test/interopR2/client.rb +9 -3
- data/test/interopR2/server.rb +1 -0
- data/test/soap/asp.net/test_aspdotnet.rb +1 -1
- data/test/soap/auth/htdigest +2 -0
- data/test/soap/auth/htpasswd +2 -0
- data/test/soap/auth/test_basic.rb +116 -0
- data/test/soap/auth/test_digest.rb +117 -0
- data/test/soap/htpasswd +2 -0
- data/test/soap/ssl/README +1 -1
- data/test/soap/ssl/test_ssl.rb +9 -9
- data/test/soap/test_cookie.rb +112 -0
- data/test/soap/test_custom_ns.rb +63 -0
- data/test/soap/test_httpconfigloader.rb +20 -5
- data/test/soap/test_mapping.rb +62 -0
- data/test/soap/test_nil.rb +55 -0
- data/test/soap/test_no_indent.rb +1 -1
- data/test/soap/test_streamhandler.rb +26 -14
- data/test/wsdl/datetime/datetimeServant.rb +1 -0
- data/test/wsdl/datetime/test_datetime.rb +4 -0
- data/test/wsdl/document/array/double.wsdl +50 -0
- data/test/wsdl/document/array/test_array.rb +34 -7
- data/test/wsdl/qualified/test_qualified.rb +1 -1
- data/test/wsdl/qualified/test_unqualified.rb +2 -16
- data/test/wsdl/rpc/test_rpc.rb +3 -0
- data/test/wsdl/rpc/test_rpc_lit.rb +1 -1
- data/test/wsdl/simpletype/rpc/expectedMappingRegistry.rb +2 -2
- data/test/wsdl/soap/wsdl2ruby/expectedMappingRegistry.rb +2 -2
- data/test/wsdl/soap/wsdl2ruby/section/test_section.rb +1 -1
- data/test/xsd/xsd2ruby/expected_mysample.rb +54 -0
- data/test/xsd/xsd2ruby/expected_mysample_mapper.rb +11 -0
- data/test/xsd/xsd2ruby/expected_mysample_mapping_registry.rb +57 -0
- data/test/xsd/xsd2ruby/section.xsd +41 -0
- data/test/xsd/xsd2ruby/test_xsd2ruby.rb +90 -0
- metadata +31 -12
- data/lib/soap/mapping/encodedregistry.rb~ +0 -531
- data/lib/tags +0 -5144
- data/lib/xsd/classloader.rb +0 -26
- data/test/interopR2/result_client.NetRemoting.txt +0 -0
- data/test/wsdl/rpc/test-rpc-lit-qualified.wsdl +0 -74
- data/test/wsdl/rpc/test-rpc-lit12.wsdl +0 -455
@@ -1,531 +0,0 @@
|
|
1
|
-
# SOAP4R - encoded mapping registry.
|
2
|
-
# Copyright (C) 2000-2003, 2006 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 'soap/baseData'
|
10
|
-
require 'soap/mapping/mapping'
|
11
|
-
require 'soap/mapping/typeMap'
|
12
|
-
require 'soap/mapping/factory'
|
13
|
-
require 'soap/mapping/rubytypeFactory'
|
14
|
-
|
15
|
-
|
16
|
-
module SOAP
|
17
|
-
module Mapping
|
18
|
-
|
19
|
-
|
20
|
-
# Inner class to pass an exception.
|
21
|
-
class SOAPException
|
22
|
-
attr_reader :excn_type_name, :cause
|
23
|
-
|
24
|
-
def initialize(e)
|
25
|
-
@excn_type_name = Mapping.name2elename(e.class.to_s)
|
26
|
-
@cause = e
|
27
|
-
end
|
28
|
-
|
29
|
-
def to_e
|
30
|
-
if @cause.is_a?(::Exception)
|
31
|
-
@cause.extend(::SOAP::Mapping::MappedException)
|
32
|
-
return @cause
|
33
|
-
elsif @cause.respond_to?(:message) and @cause.respond_to?(:backtrace)
|
34
|
-
e = RuntimeError.new(@cause.message)
|
35
|
-
e.set_backtrace(@cause.backtrace)
|
36
|
-
return e
|
37
|
-
end
|
38
|
-
klass = Mapping.class_from_name(Mapping.elename2name(@excn_type_name.to_s))
|
39
|
-
if klass.nil? or not klass <= ::Exception
|
40
|
-
return RuntimeError.new(@cause.inspect)
|
41
|
-
end
|
42
|
-
obj = klass.new(@cause.message)
|
43
|
-
obj.extend(::SOAP::Mapping::MappedException)
|
44
|
-
obj
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
|
49
|
-
class EncodedRegistry
|
50
|
-
include TraverseSupport
|
51
|
-
include RegistrySupport
|
52
|
-
|
53
|
-
class Map
|
54
|
-
def initialize(registry)
|
55
|
-
@obj2soap = {}
|
56
|
-
@soap2obj = {}
|
57
|
-
@registry = registry
|
58
|
-
end
|
59
|
-
|
60
|
-
def obj2soap(obj)
|
61
|
-
klass = obj.class
|
62
|
-
if map = @obj2soap[klass]
|
63
|
-
map.each do |soap_class, factory, info|
|
64
|
-
ret = factory.obj2soap(soap_class, obj, info, @registry)
|
65
|
-
return ret if ret
|
66
|
-
end
|
67
|
-
end
|
68
|
-
ancestors = klass.ancestors
|
69
|
-
ancestors.delete(klass)
|
70
|
-
ancestors.delete(::Object)
|
71
|
-
ancestors.delete(::Kernel)
|
72
|
-
ancestors.each do |klass|
|
73
|
-
if map = @obj2soap[klass]
|
74
|
-
map.each do |soap_class, factory, info|
|
75
|
-
if info[:derived_class]
|
76
|
-
ret = factory.obj2soap(soap_class, obj, info, @registry)
|
77
|
-
return ret if ret
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
nil
|
83
|
-
end
|
84
|
-
|
85
|
-
def soap2obj(node, klass = nil)
|
86
|
-
if map = @soap2obj[node.class]
|
87
|
-
map.each do |obj_class, factory, info|
|
88
|
-
next if klass and obj_class != klass
|
89
|
-
conv, obj = factory.soap2obj(obj_class, node, info, @registry)
|
90
|
-
return true, obj if conv
|
91
|
-
end
|
92
|
-
end
|
93
|
-
return false, nil
|
94
|
-
end
|
95
|
-
|
96
|
-
# Give priority to former entry.
|
97
|
-
def init(init_map = [])
|
98
|
-
clear
|
99
|
-
init_map.reverse_each do |obj_class, soap_class, factory, info|
|
100
|
-
add(obj_class, soap_class, factory, info)
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
# Give priority to latter entry.
|
105
|
-
def add(obj_class, soap_class, factory, info)
|
106
|
-
info ||= {}
|
107
|
-
(@obj2soap[obj_class] ||= []).unshift([soap_class, factory, info])
|
108
|
-
(@soap2obj[soap_class] ||= []).unshift([obj_class, factory, info])
|
109
|
-
end
|
110
|
-
|
111
|
-
def clear
|
112
|
-
@obj2soap.clear
|
113
|
-
@soap2obj.clear
|
114
|
-
end
|
115
|
-
|
116
|
-
def find_mapped_soap_class(target_obj_class)
|
117
|
-
map = @obj2soap[target_obj_class]
|
118
|
-
map.empty? ? nil : map[0][1]
|
119
|
-
end
|
120
|
-
|
121
|
-
def find_mapped_obj_class(target_soap_class)
|
122
|
-
map = @soap2obj[target_soap_class]
|
123
|
-
map.empty? ? nil : map[0][0]
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
StringFactory = StringFactory_.new
|
128
|
-
BasetypeFactory = BasetypeFactory_.new
|
129
|
-
DateTimeFactory = DateTimeFactory_.new
|
130
|
-
ArrayFactory = ArrayFactory_.new
|
131
|
-
Base64Factory = Base64Factory_.new
|
132
|
-
URIFactory = URIFactory_.new
|
133
|
-
TypedArrayFactory = TypedArrayFactory_.new
|
134
|
-
TypedStructFactory = TypedStructFactory_.new
|
135
|
-
|
136
|
-
HashFactory = HashFactory_.new
|
137
|
-
|
138
|
-
SOAPBaseMap = [
|
139
|
-
[::NilClass, ::SOAP::SOAPNil, BasetypeFactory],
|
140
|
-
[::TrueClass, ::SOAP::SOAPBoolean, BasetypeFactory],
|
141
|
-
[::FalseClass, ::SOAP::SOAPBoolean, BasetypeFactory],
|
142
|
-
[::String, ::SOAP::SOAPString, StringFactory,
|
143
|
-
{:derived_class => true}],
|
144
|
-
[::DateTime, ::SOAP::SOAPDateTime, DateTimeFactory],
|
145
|
-
[::Date, ::SOAP::SOAPDate, DateTimeFactory],
|
146
|
-
[::Time, ::SOAP::SOAPDateTime, DateTimeFactory],
|
147
|
-
[::Time, ::SOAP::SOAPTime, DateTimeFactory],
|
148
|
-
[::Float, ::SOAP::SOAPDouble, BasetypeFactory,
|
149
|
-
{:derived_class => true}],
|
150
|
-
[::Float, ::SOAP::SOAPFloat, BasetypeFactory,
|
151
|
-
{:derived_class => true}],
|
152
|
-
[::Integer, ::SOAP::SOAPInt, BasetypeFactory,
|
153
|
-
{:derived_class => true}],
|
154
|
-
[::Integer, ::SOAP::SOAPLong, BasetypeFactory,
|
155
|
-
{:derived_class => true}],
|
156
|
-
[::Integer, ::SOAP::SOAPInteger, BasetypeFactory,
|
157
|
-
{:derived_class => true}],
|
158
|
-
[::Integer, ::SOAP::SOAPShort, BasetypeFactory,
|
159
|
-
{:derived_class => true}],
|
160
|
-
[::Integer, ::SOAP::SOAPByte, BasetypeFactory,
|
161
|
-
{:derived_class => true}],
|
162
|
-
[::Integer, ::SOAP::SOAPNonPositiveInteger, BasetypeFactory,
|
163
|
-
{:derived_class => true}],
|
164
|
-
[::Integer, ::SOAP::SOAPNegativeInteger, BasetypeFactory,
|
165
|
-
{:derived_class => true}],
|
166
|
-
[::Integer, ::SOAP::SOAPNonNegativeInteger, BasetypeFactory,
|
167
|
-
{:derived_class => true}],
|
168
|
-
[::Integer, ::SOAP::SOAPPositiveInteger, BasetypeFactory,
|
169
|
-
{:derived_class => true}],
|
170
|
-
[::Integer, ::SOAP::SOAPUnsignedLong, BasetypeFactory,
|
171
|
-
{:derived_class => true}],
|
172
|
-
[::Integer, ::SOAP::SOAPUnsignedInt, BasetypeFactory,
|
173
|
-
{:derived_class => true}],
|
174
|
-
[::Integer, ::SOAP::SOAPUnsignedShort, BasetypeFactory,
|
175
|
-
{:derived_class => true}],
|
176
|
-
[::Integer, ::SOAP::SOAPUnsignedByte, BasetypeFactory,
|
177
|
-
{:derived_class => true}],
|
178
|
-
[::URI::Generic, ::SOAP::SOAPAnyURI, URIFactory,
|
179
|
-
{:derived_class => true}],
|
180
|
-
[::String, ::SOAP::SOAPBase64, Base64Factory],
|
181
|
-
[::String, ::SOAP::SOAPHexBinary, Base64Factory],
|
182
|
-
[::String, ::SOAP::SOAPDecimal, BasetypeFactory],
|
183
|
-
[::String, ::SOAP::SOAPDuration, BasetypeFactory],
|
184
|
-
[::String, ::SOAP::SOAPGYearMonth, BasetypeFactory],
|
185
|
-
[::String, ::SOAP::SOAPGYear, BasetypeFactory],
|
186
|
-
[::String, ::SOAP::SOAPGMonthDay, BasetypeFactory],
|
187
|
-
[::String, ::SOAP::SOAPGDay, BasetypeFactory],
|
188
|
-
[::String, ::SOAP::SOAPGMonth, BasetypeFactory],
|
189
|
-
[::String, ::SOAP::SOAPQName, BasetypeFactory],
|
190
|
-
|
191
|
-
[::Hash, ::SOAP::SOAPArray, HashFactory],
|
192
|
-
[::Hash, ::SOAP::SOAPStruct, HashFactory],
|
193
|
-
|
194
|
-
[::Array, ::SOAP::SOAPArray, ArrayFactory,
|
195
|
-
{:derived_class => true}],
|
196
|
-
|
197
|
-
[::SOAP::Mapping::SOAPException,
|
198
|
-
::SOAP::SOAPStruct, TypedStructFactory,
|
199
|
-
{:type => XSD::QName.new(RubyCustomTypeNamespace, "SOAPException")}],
|
200
|
-
]
|
201
|
-
|
202
|
-
RubyOriginalMap = [
|
203
|
-
[::NilClass, ::SOAP::SOAPNil, BasetypeFactory],
|
204
|
-
[::TrueClass, ::SOAP::SOAPBoolean, BasetypeFactory],
|
205
|
-
[::FalseClass, ::SOAP::SOAPBoolean, BasetypeFactory],
|
206
|
-
[::String, ::SOAP::SOAPString, StringFactory],
|
207
|
-
[::DateTime, ::SOAP::SOAPDateTime, DateTimeFactory],
|
208
|
-
[::Date, ::SOAP::SOAPDate, DateTimeFactory],
|
209
|
-
[::Time, ::SOAP::SOAPDateTime, DateTimeFactory],
|
210
|
-
[::Time, ::SOAP::SOAPTime, DateTimeFactory],
|
211
|
-
[::Float, ::SOAP::SOAPDouble, BasetypeFactory,
|
212
|
-
{:derived_class => true}],
|
213
|
-
[::Float, ::SOAP::SOAPFloat, BasetypeFactory,
|
214
|
-
{:derived_class => true}],
|
215
|
-
[::Integer, ::SOAP::SOAPInt, BasetypeFactory,
|
216
|
-
{:derived_class => true}],
|
217
|
-
[::Integer, ::SOAP::SOAPLong, BasetypeFactory,
|
218
|
-
{:derived_class => true}],
|
219
|
-
[::Integer, ::SOAP::SOAPInteger, BasetypeFactory,
|
220
|
-
{:derived_class => true}],
|
221
|
-
[::Integer, ::SOAP::SOAPShort, BasetypeFactory,
|
222
|
-
{:derived_class => true}],
|
223
|
-
[::Integer, ::SOAP::SOAPByte, BasetypeFactory,
|
224
|
-
{:derived_class => true}],
|
225
|
-
[::Integer, ::SOAP::SOAPNonPositiveInteger, BasetypeFactory,
|
226
|
-
{:derived_class => true}],
|
227
|
-
[::Integer, ::SOAP::SOAPNegativeInteger, BasetypeFactory,
|
228
|
-
{:derived_class => true}],
|
229
|
-
[::Integer, ::SOAP::SOAPNonNegativeInteger, BasetypeFactory,
|
230
|
-
{:derived_class => true}],
|
231
|
-
[::Integer, ::SOAP::SOAPPositiveInteger, BasetypeFactory,
|
232
|
-
{:derived_class => true}],
|
233
|
-
[::Integer, ::SOAP::SOAPUnsignedLong, BasetypeFactory,
|
234
|
-
{:derived_class => true}],
|
235
|
-
[::Integer, ::SOAP::SOAPUnsignedInt, BasetypeFactory,
|
236
|
-
{:derived_class => true}],
|
237
|
-
[::Integer, ::SOAP::SOAPUnsignedShort, BasetypeFactory,
|
238
|
-
{:derived_class => true}],
|
239
|
-
[::Integer, ::SOAP::SOAPUnsignedByte, BasetypeFactory,
|
240
|
-
{:derived_class => true}],
|
241
|
-
[::URI::Generic, ::SOAP::SOAPAnyURI, URIFactory,
|
242
|
-
{:derived_class => true}],
|
243
|
-
[::String, ::SOAP::SOAPBase64, Base64Factory],
|
244
|
-
[::String, ::SOAP::SOAPHexBinary, Base64Factory],
|
245
|
-
[::String, ::SOAP::SOAPDecimal, BasetypeFactory],
|
246
|
-
[::String, ::SOAP::SOAPDuration, BasetypeFactory],
|
247
|
-
[::String, ::SOAP::SOAPGYearMonth, BasetypeFactory],
|
248
|
-
[::String, ::SOAP::SOAPGYear, BasetypeFactory],
|
249
|
-
[::String, ::SOAP::SOAPGMonthDay, BasetypeFactory],
|
250
|
-
[::String, ::SOAP::SOAPGDay, BasetypeFactory],
|
251
|
-
[::String, ::SOAP::SOAPGMonth, BasetypeFactory],
|
252
|
-
[::String, ::SOAP::SOAPQName, BasetypeFactory],
|
253
|
-
|
254
|
-
[::Hash, ::SOAP::SOAPArray, HashFactory],
|
255
|
-
[::Hash, ::SOAP::SOAPStruct, HashFactory],
|
256
|
-
|
257
|
-
# Does not allow Array's subclass here.
|
258
|
-
[::Array, ::SOAP::SOAPArray, ArrayFactory],
|
259
|
-
|
260
|
-
[::SOAP::Mapping::SOAPException,
|
261
|
-
::SOAP::SOAPStruct, TypedStructFactory,
|
262
|
-
{:type => XSD::QName.new(RubyCustomTypeNamespace, "SOAPException")}],
|
263
|
-
]
|
264
|
-
|
265
|
-
attr_accessor :default_factory
|
266
|
-
attr_accessor :excn_handler_obj2soap
|
267
|
-
attr_accessor :excn_handler_soap2obj
|
268
|
-
|
269
|
-
def initialize(config = {})
|
270
|
-
super()
|
271
|
-
@config = config
|
272
|
-
@map = Map.new(self)
|
273
|
-
if @config[:allow_original_mapping]
|
274
|
-
@allow_original_mapping = true
|
275
|
-
@map.init(RubyOriginalMap)
|
276
|
-
else
|
277
|
-
@allow_original_mapping = false
|
278
|
-
@map.init(SOAPBaseMap)
|
279
|
-
end
|
280
|
-
@allow_untyped_struct = @config.key?(:allow_untyped_struct) ?
|
281
|
-
@config[:allow_untyped_struct] : true
|
282
|
-
@rubytype_factory = RubytypeFactory.new(
|
283
|
-
:allow_untyped_struct => @allow_untyped_struct,
|
284
|
-
:allow_original_mapping => @allow_original_mapping
|
285
|
-
)
|
286
|
-
@default_factory = @rubytype_factory
|
287
|
-
@excn_handler_obj2soap = nil
|
288
|
-
@excn_handler_soap2obj = nil
|
289
|
-
end
|
290
|
-
|
291
|
-
# initial mapping interface
|
292
|
-
# new interface Registry#register is defined in RegisterSupport
|
293
|
-
def add(obj_class, soap_class, factory, info = nil)
|
294
|
-
@map.add(obj_class, soap_class, factory, info)
|
295
|
-
end
|
296
|
-
alias set add
|
297
|
-
|
298
|
-
# general Registry ignores type_qname
|
299
|
-
def obj2soap(obj, type_qname = nil)
|
300
|
-
soap = _obj2soap(obj)
|
301
|
-
if @allow_original_mapping
|
302
|
-
addextend2soap(soap, obj)
|
303
|
-
end
|
304
|
-
soap
|
305
|
-
end
|
306
|
-
|
307
|
-
def soap2obj(node, klass = nil)
|
308
|
-
obj = _soap2obj(node, klass)
|
309
|
-
if @allow_original_mapping
|
310
|
-
addextend2obj(obj, node.extraattr[RubyExtendName])
|
311
|
-
addiv2obj(obj, node.extraattr[RubyIVarName])
|
312
|
-
end
|
313
|
-
obj
|
314
|
-
end
|
315
|
-
|
316
|
-
def find_mapped_soap_class(obj_class)
|
317
|
-
@map.find_mapped_soap_class(obj_class)
|
318
|
-
end
|
319
|
-
|
320
|
-
def find_mapped_obj_class(soap_class)
|
321
|
-
@map.find_mapped_obj_class(soap_class)
|
322
|
-
end
|
323
|
-
|
324
|
-
private
|
325
|
-
|
326
|
-
def _obj2soap(obj)
|
327
|
-
ret = nil
|
328
|
-
if obj.is_a?(SOAPStruct) or obj.is_a?(SOAPArray)
|
329
|
-
obj.replace do |ele|
|
330
|
-
Mapping._obj2soap(ele, self)
|
331
|
-
end
|
332
|
-
return obj
|
333
|
-
elsif obj.is_a?(SOAPBasetype)
|
334
|
-
return obj
|
335
|
-
end
|
336
|
-
begin
|
337
|
-
if definition = schema_definition_from_class(obj.class)
|
338
|
-
return stubobj2soap(obj, definition)
|
339
|
-
end
|
340
|
-
ret = @map.obj2soap(obj) ||
|
341
|
-
@default_factory.obj2soap(nil, obj, nil, self)
|
342
|
-
return ret if ret
|
343
|
-
rescue MappingError
|
344
|
-
end
|
345
|
-
if @excn_handler_obj2soap
|
346
|
-
ret = @excn_handler_obj2soap.call(obj) { |yield_obj|
|
347
|
-
Mapping._obj2soap(yield_obj, self)
|
348
|
-
}
|
349
|
-
return ret if ret
|
350
|
-
end
|
351
|
-
raise MappingError.new("Cannot map #{ obj.class.name } to SOAP/OM.")
|
352
|
-
end
|
353
|
-
|
354
|
-
# Might return nil as a mapping result.
|
355
|
-
def _soap2obj(node, klass = nil)
|
356
|
-
if klass
|
357
|
-
definition = schema_definition_from_class(klass)
|
358
|
-
else
|
359
|
-
if definition = schema_definition_from_elename(node.elename)
|
360
|
-
klass = definition.class_for
|
361
|
-
elsif definition = schema_definition_from_type(node.type)
|
362
|
-
klass = definition.class_for
|
363
|
-
end
|
364
|
-
end
|
365
|
-
if definition and node.is_a?(::SOAP::SOAPStruct)
|
366
|
-
return elesoap2stubobj(node, klass, definition)
|
367
|
-
end
|
368
|
-
if node.extraattr.key?(RubyTypeName)
|
369
|
-
conv, obj = @rubytype_factory.soap2obj(nil, node, nil, self)
|
370
|
-
return obj if conv
|
371
|
-
end
|
372
|
-
conv, obj = @map.soap2obj(node, klass)
|
373
|
-
return obj if conv
|
374
|
-
conv, obj = @default_factory.soap2obj(nil, node, nil, self)
|
375
|
-
return obj if conv
|
376
|
-
if @excn_handler_soap2obj
|
377
|
-
begin
|
378
|
-
return @excn_handler_soap2obj.call(node) { |yield_node|
|
379
|
-
Mapping._soap2obj(yield_node, self)
|
380
|
-
}
|
381
|
-
rescue Exception
|
382
|
-
end
|
383
|
-
end
|
384
|
-
raise MappingError.new("Cannot map #{ node.type.name } to Ruby object.")
|
385
|
-
end
|
386
|
-
|
387
|
-
def addiv2obj(obj, attr)
|
388
|
-
return unless attr
|
389
|
-
vars = {}
|
390
|
-
attr.__getobj__.each do |name, value|
|
391
|
-
vars[name] = Mapping._soap2obj(value, self)
|
392
|
-
end
|
393
|
-
Mapping.set_attributes(obj, vars)
|
394
|
-
end
|
395
|
-
|
396
|
-
if RUBY_VERSION >= '1.8.0'
|
397
|
-
def addextend2obj(obj, attr)
|
398
|
-
return unless attr
|
399
|
-
attr.split(/ /).reverse_each do |mstr|
|
400
|
-
obj.extend(Mapping.module_from_name(mstr))
|
401
|
-
end
|
402
|
-
end
|
403
|
-
else
|
404
|
-
# (class < false; self; end).ancestors includes "TrueClass" under 1.6...
|
405
|
-
def addextend2obj(obj, attr)
|
406
|
-
return unless attr
|
407
|
-
attr.split(/ /).reverse_each do |mstr|
|
408
|
-
m = Mapping.module_from_name(mstr)
|
409
|
-
obj.extend(m)
|
410
|
-
end
|
411
|
-
end
|
412
|
-
end
|
413
|
-
|
414
|
-
def addextend2soap(node, obj)
|
415
|
-
return if obj.is_a?(Symbol) or obj.is_a?(Fixnum)
|
416
|
-
list = (class << obj; self; end).ancestors - obj.class.ancestors
|
417
|
-
unless list.empty?
|
418
|
-
node.extraattr[RubyExtendName] = list.collect { |c|
|
419
|
-
name = c.name
|
420
|
-
if name.nil? or name.empty?
|
421
|
-
raise TypeError.new("singleton can't be dumped #{ obj }")
|
422
|
-
end
|
423
|
-
name
|
424
|
-
}.join(" ")
|
425
|
-
end
|
426
|
-
end
|
427
|
-
|
428
|
-
def stubobj2soap(obj, definition)
|
429
|
-
case obj
|
430
|
-
when ::Array
|
431
|
-
array2soap(obj, definition)
|
432
|
-
else
|
433
|
-
return unknownstubobj2soap(obj, definition)
|
434
|
-
end
|
435
|
-
end
|
436
|
-
|
437
|
-
def array2soap(obj, definition)
|
438
|
-
return SOAPNil.new if obj.nil? # ToDo: check nillable.
|
439
|
-
arytype = definition.elements[0].elename
|
440
|
-
soap_obj = SOAPArray.new(ValueArrayName, 1, arytype)
|
441
|
-
mark_marshalled_obj(obj, soap_obj)
|
442
|
-
obj.each do |item|
|
443
|
-
soap_obj.add(Mapping._obj2soap(item, self, arytype))
|
444
|
-
end
|
445
|
-
soap_obj
|
446
|
-
end
|
447
|
-
|
448
|
-
def unknownstubobj2soap(obj, definition)
|
449
|
-
return SOAPNil.new if obj.nil?
|
450
|
-
if definition.elements.size == 0
|
451
|
-
ele = Mapping.obj2soap(obj)
|
452
|
-
ele.elename = definition.elename if definition.elename
|
453
|
-
return ele
|
454
|
-
else
|
455
|
-
ele = SOAPStruct.new(definition.type)
|
456
|
-
mark_marshalled_obj(obj, ele)
|
457
|
-
end
|
458
|
-
definition.elements.each do |eledef|
|
459
|
-
name = eledef.elename.name
|
460
|
-
if child = Mapping.get_attribute(obj, eledef.varname)
|
461
|
-
if eledef.as_array?
|
462
|
-
child.each do |item|
|
463
|
-
ele.add(name, Mapping._obj2soap(item, self))
|
464
|
-
end
|
465
|
-
else
|
466
|
-
ele.add(name, Mapping._obj2soap(child, self))
|
467
|
-
end
|
468
|
-
elsif obj.respond_to?(:each) and eledef.as_array?
|
469
|
-
obj.each do |item|
|
470
|
-
ele.add(name, Mapping._obj2soap(item, self))
|
471
|
-
end
|
472
|
-
end
|
473
|
-
end
|
474
|
-
ele
|
475
|
-
end
|
476
|
-
|
477
|
-
def elesoap2stubobj(node, obj_class, definition)
|
478
|
-
obj = Mapping.create_empty_object(obj_class)
|
479
|
-
add_elesoap2stubobj(node, obj, definition)
|
480
|
-
obj
|
481
|
-
end
|
482
|
-
|
483
|
-
# XXX consider to merge with the method in LiteralRegistry
|
484
|
-
def add_elesoap2stubobj(node, obj, definition)
|
485
|
-
vars = {}
|
486
|
-
node.each do |name, value|
|
487
|
-
item = definition.elements.find { |k, v|
|
488
|
-
k.elename == value.elename
|
489
|
-
}
|
490
|
-
if item
|
491
|
-
child = soap2typedobj(value, item.mapped_class)
|
492
|
-
else
|
493
|
-
# unknown element is treated as anyType.
|
494
|
-
child = Mapping._soap2obj(value, self)
|
495
|
-
end
|
496
|
-
if item and item.as_array?
|
497
|
-
(vars[name] ||= []) << child
|
498
|
-
elsif vars.key?(name)
|
499
|
-
vars[name] = [vars[name], child].flatten
|
500
|
-
else
|
501
|
-
vars[name] = child
|
502
|
-
end
|
503
|
-
end
|
504
|
-
if obj.is_a?(::Array) and vars.keys.size == 1
|
505
|
-
obj.replace(vars.values[0])
|
506
|
-
else
|
507
|
-
Mapping.set_attributes(obj, vars)
|
508
|
-
end
|
509
|
-
end
|
510
|
-
|
511
|
-
def soap2typedobj(value, klass)
|
512
|
-
unless klass
|
513
|
-
raise MappingError.new("unknown class: #{klass}")
|
514
|
-
end
|
515
|
-
if klass.ancestors.include?(::SOAP::SOAPBasetype)
|
516
|
-
obj = base2obj(value, klass)
|
517
|
-
else
|
518
|
-
obj = Mapping._soap2obj(value, self, klass)
|
519
|
-
end
|
520
|
-
obj
|
521
|
-
end
|
522
|
-
end
|
523
|
-
|
524
|
-
|
525
|
-
Registry = EncodedRegistry
|
526
|
-
DefaultRegistry = EncodedRegistry.new
|
527
|
-
RubyOriginalRegistry = EncodedRegistry.new(:allow_original_mapping => true)
|
528
|
-
|
529
|
-
|
530
|
-
end
|
531
|
-
end
|