Changeset 1632
- Timestamp:
- 09/23/05 14:11:38 (3 years ago)
- Files:
-
- trunk/lib/soap/mapping/wsdlliteralregistry.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/soap/mapping/wsdlliteralregistry.rb
r1631 r1632 121 121 o.qualified = qualified 122 122 type.each_element do |child_ele| 123 child = Mapping.get_attribute(obj, child_ele.name.name) 124 if child.nil? 125 if child_ele.nillable 126 # ToDo: test 127 # add empty element 128 child_soap = obj2elesoap(nil, child_ele) 123 if child_ele.map_as_array? 124 child = Mapping.get_attribute(obj, child_ele.name.name) 125 if child.nil? and obj.is_a?(::Array) 126 child = obj 127 end 128 if child.nil? 129 child_soap = nil2soap(child_ele) 130 o.add(child_soap) if child_soap 131 else 132 child.each do |item| 133 child_soap = obj2elesoap(item, child_ele) 134 o.add(child_soap) 135 end 136 end 137 else 138 child = Mapping.get_attribute(obj, child_ele.name.name) 139 if child.nil? 140 child_soap = nil2soap(child_ele) 141 o.add(child_soap) if child_soap 142 else 143 child_soap = obj2elesoap(child, child_ele) 129 144 o.add(child_soap) 130 elsif Integer(child_ele.minoccurs) == 0 131 # nothing to do 132 else 133 raise MappingError.new("nil not allowed: #{child_ele.name.name}") 134 end 135 elsif child_ele.map_as_array? 136 child.each do |item| 137 child_soap = obj2elesoap(item, child_ele) 138 o.add(child_soap) 139 end 140 else 141 child_soap = obj2elesoap(child, child_ele) 142 o.add(child_soap) 145 end 143 146 end 144 147 end 145 148 o 149 end 150 151 def nil2soap(ele) 152 if ele.nillable 153 obj2elesoap(nil, ele) # add an empty element 154 elsif Integer(ele.minoccurs) == 0 155 nil # intends no element 156 else 157 raise MappingError.new("nil not allowed: #{ele.name.name}") 158 end 146 159 end 147 160