Changeset 1448
- Timestamp:
- 02/22/05 09:51:36 (4 years ago)
- Files:
-
- trunk/sample/soap/customfactory.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/sample/soap/customfactory.rb
r1447 r1448 51 51 end 52 52 53 class ExplicitTypedArrayFactory < SOAP::Mapping::Factory 54 def obj2soap(soap_class, obj, info, map) 55 unless obj.respond_to?(:arytype) 56 return nil 57 end 58 soap_obj = soap_class.new(ValueArrayName, 1, obj.arytype) 59 mark_marshalled_obj(obj, soap_obj) 60 obj.each do |item| 61 child = Mapping._obj2soap(item, map) 62 soap_obj.add(child) 63 end 64 soap_obj 65 end 66 67 # let default TypedArrayFactory handle that. 68 def soap2obj(obj_class, node, info, map) 69 return false 70 end 71 end 72 53 73 map = Mapping::Registry.new 54 74 map.set(DummyStruct, SOAPStruct, DummyStructFactory.new) 75 map.set(Array, SOAPArray, ExplicitTypedArrayFactory.new) 76 77 puts 78 puts "== DummyStruct ==" 79 puts 55 80 56 81 obj = DummyStruct.new('family' => 'Na', 'given' => 'Hi') 57 82 puts marshalledstring = SOAPMarshal.marshal(obj, map) 83 p SOAPMarshal.unmarshal(marshalledstring, map) 58 84 85 puts 86 puts "== Custom array ==" 87 puts 88 89 obj1 = [1, 2, 3] 90 obj2 = [4, 5, 6] 91 def obj1.arytype 92 XSD::XSDInt::Type 93 end 94 95 puts marshalledstring = SOAPMarshal.marshal(obj1, map) 59 96 p SOAPMarshal.unmarshal(marshalledstring, map) 97 puts marshalledstring = SOAPMarshal.marshal(obj2, map) 98 p SOAPMarshal.unmarshal(marshalledstring, map)