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

Changeset 1040

Show
Ignore:
Timestamp:
11/13/03 23:48:34 (5 years ago)
Author:
nahi
Message:

Support Axis's halfway typed multi-ref array.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/soap/encodingstyle/soapHandler.rb

    r1021 r1040  
    173173      o = SOAPReference.decode(elename, href) 
    174174      @refpool << o 
    175     elsif @decode_typemap && 
    176         (parent.node.class != SOAPBody || @is_first_top_ele) 
    177       # multi-ref element should be parsed by decode_tag_by_type. 
    178       @is_first_top_ele = false 
     175    elsif @decode_typemap 
     176        # to parse multi-ref element with decode_tag_by_type. 
     177        # && (parent.node.class != SOAPBody || @is_first_top_ele) 
    179178      o = decode_tag_by_wsdl(ns, elename, type, parent.node, arytype, extraattr) 
    180179    else 
     
    345344 
    346345  def decode_tag_by_wsdl(ns, elename, typestr, parent, arytypestr, extraattr) 
     346    o = nil 
    347347    if parent.class == SOAPBody 
    348       # Unqualified name is allowed here. 
    349       type = @decode_typemap[elename] || @decode_typemap.find_name(elename.name) 
    350       unless type 
    351         raise EncodingStyleError.new("Unknown operation '#{ elename }'.") 
    352       end 
    353       o = SOAPStruct.new(elename) 
    354       o.definedtype = type 
    355       return o 
     348      if @is_first_top_ele 
     349        # Unqualified name is allowed here. 
     350        @is_first_top_ele = false 
     351        type = @decode_typemap[elename] || 
     352          @decode_typemap.find_name(elename.name) 
     353        unless type 
     354          raise EncodingStyleError.new("Unknown operation '#{ elename }'.") 
     355        end 
     356        o = SOAPStruct.new(elename) 
     357        o.definedtype = type 
     358        return o 
     359      elsif !typestr 
     360        # typeless multi-ref element. 
     361        return decode_tag_by_type(ns, elename, typestr, parent, arytypestr, 
     362          extraattr) 
     363      else 
     364        # typed multi-ref element. 
     365        typename = ns.parse(typestr) 
     366        typedef = @decode_typemap[typename] 
     367        return decode_defined_compoundtype(elename, typename, typedef, 
     368          arytypestr) 
     369      end 
    356370    end 
    357371 
     
    367381      raise EncodingStyleError.new("Unknown type '#{ parent.type }'.") 
    368382    end 
    369     typename = parenttype.child_type(elename) 
    370     if typename 
    371       if (klass = TypeMap[typename]) 
    372        return klass.decode(elename) 
    373       elsif typename == XSD::AnyTypeName 
    374        return decode_tag_by_type(ns, elename, typestr, parent, arytypestr, 
    375           extraattr) 
    376       end 
    377     end 
    378  
    379     type = if typename 
    380         @decode_typemap[typename] 
    381       else 
    382         parenttype.child_defined_complextype(elename) 
    383       end 
    384     unless type 
     383 
     384    definedtype_name = parenttype.child_type(elename) 
     385    if definedtype_name and (klass = TypeMap[definedtype_name]) 
     386      return klass.decode(elename) 
     387    elsif definedtype_name == XSD::AnyTypeName 
     388      return decode_tag_by_type(ns, elename, typestr, parent, arytypestr, 
     389        extraattr) 
     390    end 
     391 
     392    typedef = definedtype_name ? @decode_typemap[definedtype_name] : 
     393      parenttype.child_defined_complextype(elename) 
     394    decode_defined_compoundtype(elename, definedtype_name, typedef, arytypestr) 
     395  end 
     396 
     397  def decode_defined_compoundtype(elename, typename, typedef, arytypestr) 
     398    unless typedef 
    385399      raise EncodingStyleError.new("Unknown type '#{ typename }'.") 
    386400    end 
    387  
    388     case type.compoundtype 
     401    case typedef.compoundtype 
    389402    when :TYPE_STRUCT 
    390403      o = SOAPStruct.decode(elename, typename) 
    391       o.definedtype = type 
     404      o.definedtype = typedef 
    392405      return o 
    393406    when :TYPE_ARRAY 
    394       expected_arytype = type.find_arytype 
    395       actual_arytype = if arytypestr 
    396           XSD::QName.new(expected_arytype.namespace, 
    397             content_typename(expected_arytype.name) << 
    398             content_ranksize(arytypestr)) 
    399         else 
    400           expected_arytype 
    401         end 
    402       o = SOAPArray.decode(elename, typename, actual_arytype) 
    403       o.definedtype = type 
     407      expected_arytype = typedef.find_arytype 
     408      if arytypestr 
     409        actual_arytype = XSD::QName.new(expected_arytype.namespace, 
     410          content_typename(expected_arytype.name) << 
     411          content_ranksize(arytypestr)) 
     412        o = SOAPArray.decode(elename, typename, actual_arytype) 
     413      else 
     414        o = SOAPArray.new(typename, 1, expected_arytype) 
     415        o.elename = elename 
     416      end 
     417      o.definedtype = typedef 
    404418      return o 
    405419    end