Welcome to the "trac"-ing site of soap4r!
[soap4r] [httpclient] [openpgp4u] [pkcs1] [logger] [csv] [vtr]

Changeset 1632

Show
Ignore:
Timestamp:
09/23/05 14:11:38 (3 years ago)
Author:
nahi
Message:

let obj2soap mapper of WSDLLiteralRegistry (a registry for literal service) handle an Array. fix for #150.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/soap/mapping/wsdlliteralregistry.rb

    r1631 r1632  
    121121    o.qualified = qualified 
    122122    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) 
    129144          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 
    143146      end 
    144147    end 
    145148    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 
    146159  end 
    147160