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

Changeset 1934

Show
Ignore:
Timestamp:
09/03/07 22:41:04 (9 months ago)
Author:
nahi
Message:
  • anonymous class support was incomplete for Array type complexType. for literal registry, scan inside of Array like complexType. closes #355.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/wsdl/soap/classDefCreator.rb

    r1915 r1934  
    4343  def dump(type = nil) 
    4444    result = "require 'xsd/qname'\n" 
     45    # cannot use create_class_name with @modulepath because of multiple classes 
    4546    if @modulepath 
    4647      result << "\n" 
    47       result << @modulepath.collect { |ele| "module #{ele}" }.join("; ") 
     48      result << modulepath_split(@modulepath).collect { |ele| "module #{ele}" }.join("; ") 
    4849      result << "\n\n" 
    4950    end 
     
    7980    if @modulepath 
    8081      result << "\n\n" 
    81       result << @modulepath.collect { |ele| "end" }.join("; ") 
     82      result << modulepath_split(@modulepath).collect { |ele| "end" }.join("; ") 
    8283      result << "\n" 
    8384    end 
     
    276277  end 
    277278 
    278   def parse_elements(c, elements, base_namespace, parentmodule
     279  def parse_elements(c, elements, base_namespace, parentmodule, as_array = false
    279280    init_lines = [] 
    280281    init_params = [] 
     
    298299        if element.anonymous_type? 
    299300          inner = create_classdef(element.name, element.local_complextype) 
    300           inner.comment = "inner class for member: #{name}\n" + inner.comment 
     301          unless as_array 
     302            inner.comment = "inner class for member: #{name}\n" + inner.comment 
     303          end 
    301304          c.innermodule << inner 
    302305          typebase = parentmodule 
    303306        end 
    304         attrname = safemethodname(name) 
    305         varname = safevarname(name) 
    306         c.def_attr(attrname, true, varname) 
    307         init_lines << "@#{varname} = #{varname}" 
    308         if element.map_as_array? 
    309           init_params << "#{varname} = []" 
    310         else 
    311           init_params << "#{varname} = nil" 
     307        unless as_array 
     308          attrname = safemethodname(name) 
     309          varname = safevarname(name) 
     310          c.def_attr(attrname, true, varname) 
     311          init_lines << "@#{varname} = #{varname}" 
     312          if element.map_as_array? 
     313            init_params << "#{varname} = []" 
     314          else 
     315            init_params << "#{varname} = nil" 
     316          end 
     317          c.comment << "\n  #{attrname} - #{create_type_name(element, typebase) || '(any)'}" 
    312318        end 
    313         c.comment << "\n  #{attrname} - #{create_type_name(element, typebase) || '(any)'}" 
    314319      when WSDL::XMLSchema::Sequence 
    315320        child_init_lines, child_init_params = 
    316           parse_elements(c, element.elements, base_namespace, parentmodule
     321          parse_elements(c, element.elements, base_namespace, parentmodule, as_array
    317322        init_lines.concat(child_init_lines) 
    318323        init_params.concat(child_init_params) 
    319324      when WSDL::XMLSchema::Choice 
    320325        child_init_lines, child_init_params = 
    321           parse_elements(c, element.elements, base_namespace, parentmodule
     326          parse_elements(c, element.elements, base_namespace, parentmodule, as_array
    322327        init_lines.concat(child_init_lines) 
    323328        init_params.concat(child_init_params) 
     
    328333        end 
    329334        child_init_lines, child_init_params = 
    330           parse_elements(c, element.content.elements, base_namespace, parentmodule
     335          parse_elements(c, element.content.elements, base_namespace, parentmodule, as_array
    331336        init_lines.concat(child_init_lines) 
    332337        init_params.concat(child_init_params) 
     
    367372  end 
    368373 
    369   def dump_arraydef(qname, complextype
     374  def dump_arraydef(qname, typedef
    370375    classname = create_class_name(qname) 
    371376    check_classname(classname) 
    372377    c = ClassDef.new(classname, '::Array') 
    373378    c.comment = "#{qname}" 
     379    parse_elements(c, typedef.elements, qname.namespace, classname, true) 
    374380    c.dump 
    375381  end 
     
    404410    result 
    405411  end 
     412 
     413  def modulepath_split(modulepath) 
     414    if modulepath.is_a?(::Array) 
     415      modulepath 
     416    else 
     417      modulepath.to_s.split('::') 
     418    end 
     419  end 
    406420end 
    407421 
  • trunk/lib/wsdl/soap/encodedMappingRegistryCreator.rb

    r1915 r1934  
    6666      dump_struct_typemap(qname, typedef) 
    6767    when :TYPE_ARRAY 
    68       dump_array_typemap(qname, typedef) 
     68      dump_encoded_array_typemap(qname, typedef) 
    6969    when :TYPE_SIMPLE 
    7070      dump_simple_typemap(qname, typedef) 
    7171    when :TYPE_MAP 
     72      # mapped as a general Hash 
    7273      nil 
    7374    else 
    74       raise NotImplementedError.new("must not reach here: #{typedef.compoundtype}") 
     75      raise RuntimeError.new( 
     76        "unknown kind of complexContent: #{typedef.compoundtype}") 
    7577    end 
    7678  end 
    7779 
    78   def dump_array_typemap(qname, typedef) 
     80  def dump_encoded_array_typemap(qname, typedef) 
    7981    arytype = typedef.find_arytype || XSD::AnyTypeName 
    8082    type = XSD::QName.new(arytype.namespace, arytype.name.sub(/\[(?:,)*\]$/, '')) 
  • trunk/lib/wsdl/soap/literalMappingRegistryCreator.rb

    r1923 r1934  
    122122 
    123123  def dump_array_typemap(qname, typedef) 
     124    @dump_struct_typemap_innerstruct = [] 
     125    @dump_struct_typemap_innerstruct.unshift( 
     126      dump_literal_array_typemap(qname, typedef)) 
     127    @dump_struct_typemap_innerstruct.join("\n") 
     128  end 
     129 
     130  def dump_literal_array_typemap(qname, typedef) 
    124131    var = {} 
    125132    var[:class] = create_class_name(qname, @modulepath) 
     
    132139      var[:schema_type] = qname 
    133140    end 
     141    parentmodule = var[:class] 
     142    parsed_element = parse_elements(typedef.elements, qname.namespace, 
     143      parentmodule, nil) 
     144    if parsed_element.empty? 
     145      parsed_element = [create_soapenc_array_element_definition(typedef)] 
     146    end 
     147    var[:schema_element] = dump_schema_element_definition(parsed_element, 2) 
     148    assign_const(schema_ns, 'Ns') 
     149    dump_entry(@varname, var) 
     150  end 
     151 
     152  def create_soapenc_array_element_definition(typedef) 
    134153    child_type = typedef.child_type 
    135154    child_element = typedef.find_aryelement 
     
    158177      child_element_name = DEFAULT_ITEM_NAME 
    159178    end 
    160     parsed_element = [] 
    161     parsed_element << [child_element_name.name, child_element_name, type, occurrence] 
    162     var[:schema_element] = dump_schema_element_definition(parsed_element, 2) 
    163     assign_const(schema_ns, 'Ns') 
    164     dump_entry(@varname, var) 
     179    [child_element_name.name, child_element_name, type, occurrence] 
    165180  end 
    166181end 
  • trunk/test/wsdl/anonymous/expectedClassDef.rb

    r1915 r1934  
    11require 'xsd/qname' 
    22 
    3 module WSDL::Anonymous 
     3module WSDL; module Anonymous 
    44 
     5 
     6# {urn:lp}ExtraInfo 
     7class ExtraInfo < ::Array 
     8 
     9  # {}Entry 
     10  #   key - SOAP::SOAPString 
     11  #   value - SOAP::SOAPString 
     12  class Entry 
     13    attr_accessor :key 
     14    attr_accessor :value 
     15 
     16    def initialize(key = nil, value = nil) 
     17      @key = key 
     18      @value = value 
     19    end 
     20  end 
     21end 
    522 
    623# {urn:lp}loginResponse 
     
    5572 
    5673 
    57 end 
     74end; end 
  • trunk/test/wsdl/anonymous/expectedMappingRegistry.rb

    r1923 r1934  
    88  LiteralRegistry = ::SOAP::Mapping::LiteralRegistry.new 
    99  NsLp = "urn:lp" 
     10  NsXMLSchema = "http://www.w3.org/2001/XMLSchema" 
     11 
     12  EncodedRegistry.set( 
     13    WSDL::Anonymous::ExtraInfo, 
     14    ::SOAP::SOAPArray, 
     15    ::SOAP::Mapping::EncodedRegistry::TypedArrayFactory, 
     16    { :type => XSD::QName.new(NsXMLSchema, "anyType") } 
     17  ) 
    1018 
    1119  EncodedRegistry.register( 
     
    2230    :schema_element => [ 
    2331      ["sessionID", "SOAP::SOAPString"] 
     32    ] 
     33  ) 
     34 
     35  LiteralRegistry.register( 
     36    :class => WSDL::Anonymous::ExtraInfo, 
     37    :schema_type => XSD::QName.new(NsLp, "ExtraInfo"), 
     38    :schema_element => [ 
     39      ["entry", ["WSDL::Anonymous::ExtraInfo::Entry[]", XSD::QName.new(nil, "Entry")], [1, nil]] 
     40    ] 
     41  ) 
     42 
     43  LiteralRegistry.register( 
     44    :class => WSDL::Anonymous::ExtraInfo::Entry, 
     45    :schema_name => XSD::QName.new(nil, "Entry"), 
     46    :schema_element => [ 
     47      ["key", ["SOAP::SOAPString", XSD::QName.new(nil, "Key")]], 
     48      ["value", ["SOAP::SOAPString", XSD::QName.new(nil, "Value")]] 
    2449    ] 
    2550  ) 
  • trunk/test/wsdl/anonymous/lp.wsdl

    r1915 r1934  
    99  <types> 
    1010    <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:lp"> 
     11      <complexType name="ExtraInfo"> 
     12        <annotation> 
     13          <documentation>Service specific information.</documentation> 
     14        </annotation> 
     15        <sequence> 
     16          <element maxOccurs="unbounded" name="Entry"> 
     17            <complexType> 
     18              <sequence> 
     19                <element name="Key" type="xsd:string"/> 
     20                <element name="Value" type="xsd:string"/> 
     21              </sequence> 
     22            </complexType> 
     23          </element> 
     24        </sequence> 
     25      </complexType> 
     26 
    1127      <element name="login"> 
    1228        <complexType> 
  • trunk/test/wsdl/any/expectedEcho.rb

    r1915 r1934  
    11require 'xsd/qname' 
    22 
    3 module WSDL::Any 
     3module WSDL; module Any 
    44 
    55 
     
    5555 
    5656 
    57 end 
     57end; end 
  • trunk/test/wsdl/group/expectedClassdef.rb

    r1917 r1934  
    11require 'xsd/qname' 
    22 
    3 module WSDL::Group 
     3module WSDL; module Group 
    44 
    55 
     
    5656 
    5757 
    58 end 
     58end; end 
  • trunk/test/wsdl/raa/expectedClassDef.rb

    r1933 r1934  
    11require 'xsd/qname' 
    22 
    3 module WSDL::RAA 
     3module WSDL; module RAA 
    44 
    55 
    66# {http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/}Category 
     7#   major - SOAP::SOAPString 
     8#   minor - SOAP::SOAPString 
    79class Category 
    810  attr_accessor :major 
     
    1618 
    1719# {http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/}Product 
     20#   id - SOAP::SOAPInt 
     21#   name - SOAP::SOAPString 
     22#   short_description - SOAP::SOAPString 
     23#   version - SOAP::SOAPString 
     24#   status - SOAP::SOAPString 
     25#   homepage - SOAP::SOAPAnyURI 
     26#   download - SOAP::SOAPAnyURI 
     27#   license - SOAP::SOAPString 
     28#   description - SOAP::SOAPString 
    1829class Product 
    1930  attr_accessor :id 
     
    4152 
    4253# {http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/}Owner 
     54#   id - SOAP::SOAPInt 
     55#   email - SOAP::SOAPAnyURI 
     56#   name - SOAP::SOAPString 
    4357class Owner 
    4458  attr_accessor :id 
     
    5468 
    5569# {http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/}Info 
     70#   category - WSDL::RAA::Category 
     71#   product - WSDL::RAA::Product 
     72#   owner - WSDL::RAA::Owner 
     73#   created - SOAP::SOAPDateTime 
     74#   updated - SOAP::SOAPDateTime 
    5675class Info 
    5776  attr_accessor :category 
     
    7998 
    8099 
    81 end 
     100end; end 
  • trunk/test/wsdl/raa/expectedDriver.rb

    r1933 r1934  
    11require 'RAA.rb' 
    22require 'RAAMappingRegistry.rb' 
     3require 'soap/rpc/driver' 
    34 
    45module WSDL::RAA 
    5 require 'soap/rpc/driver' 
    66 
    77class RAABaseServicePortType < ::SOAP::RPC::Driver 
    88  DefaultEndpointUrl = "http://raa.ruby-lang.org/soap/1.0.2/" 
     9  NsC_002 = "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/" 
    910 
    1011  Methods = [ 
    11     [ XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "getAllListings"), 
     12    [ XSD::QName.new(NsC_002, "getAllListings"), 
    1213      "", 
    1314      "getAllListings", 
    14       [ ["retval", "return", ["WSDL::RAA::C_String[]", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "StringArray"]] ], 
     15      [ ["retval", "return", ["WSDL::RAA::StringArray", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "StringArray"]] ], 
    1516      { :request_style =>  :rpc, :request_use =>  :encoded, 
    1617        :response_style => :rpc, :response_use => :encoded, 
    1718        :faults => {} } 
    1819    ], 
    19     [ XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "getProductTree"), 
     20    [ XSD::QName.new(NsC_002, "getProductTree"), 
    2021      "", 
    2122      "getProductTree", 
     
    2526        :faults => {} } 
    2627    ], 
    27     [ XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "getInfoFromCategory"), 
     28    [ XSD::QName.new(NsC_002, "getInfoFromCategory"), 
    2829      "", 
    2930      "getInfoFromCategory", 
    3031      [ ["in", "category", ["WSDL::RAA::Category", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Category"]], 
    31         ["retval", "return", ["WSDL::RAA::Info[]", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "InfoArray"]] ], 
     32        ["retval", "return", ["WSDL::RAA::InfoArray", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "InfoArray"]] ], 
    3233      { :request_style =>  :rpc, :request_use =>  :encoded, 
    3334        :response_style => :rpc, :response_use => :encoded, 
    3435        :faults => {} } 
    3536    ], 
    36     [ XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "getModifiedInfoSince"), 
     37    [ XSD::QName.new(NsC_002, "getModifiedInfoSince"), 
    3738      "", 
    3839      "getModifiedInfoSince", 
    3940      [ ["in", "timeInstant", ["::SOAP::SOAPDateTime"]], 
    40         ["retval", "return", ["WSDL::RAA::Info[]", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "InfoArray"]] ], 
     41        ["retval", "return", ["WSDL::RAA::InfoArray", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "InfoArray"]] ], 
    4142      { :request_style =>  :rpc, :request_use =>  :encoded, 
    4243        :response_style => :rpc, :response_use => :encoded, 
    4344        :faults => {} } 
    4445    ], 
    45     [ XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "getInfoFromName"), 
     46    [ XSD::QName.new(NsC_002, "getInfoFromName"), 
    4647      "", 
    4748      "getInfoFromName", 
     
    5253        :faults => {} } 
    5354    ], 
    54     [ XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "getInfoFromOwnerId"), 
     55    [ XSD::QName.new(NsC_002, "getInfoFromOwnerId"), 
    5556      "", 
    5657      "getInfoFromOwnerId", 
    5758      [ ["in", "ownerId", ["::SOAP::SOAPInt"]], 
    58         ["retval", "return", ["WSDL::RAA::Info[]", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "InfoArray"]] ], 
     59        ["retval", "return", ["WSDL::RAA::InfoArray", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "InfoArray"]] ], 
    5960      { :request_style =>  :rpc, :request_use =>  :encoded, 
    6061        :response_style => :rpc, :response_use => :encoded, 
  • trunk/test/wsdl/raa/expectedMappingRegistry.rb

    r1933 r1934  
    77  EncodedRegistry = ::SOAP::Mapping::EncodedRegistry.new 
    88  LiteralRegistry = ::SOAP::Mapping::LiteralRegistry.new 
     9  NsC_002 = "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/" 
     10  NsXMLSchema = "http://www.w3.org/2001/XMLSchema" 
    911 
    1012  EncodedRegistry.register( 
    1113    :class => WSDL::RAA::Category, 
    12     :schema_ns => "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", 
    13     :schema_type => "Category", 
     14    :schema_type => XSD::QName.new(NsC_002, "Category"), 
    1415    :schema_element => [ 
    1516      ["major", ["SOAP::SOAPString", XSD::QName.new(nil, "major")]], 
     
    2021  EncodedRegistry.register( 
    2122    :class => WSDL::RAA::Product, 
    22     :schema_ns => "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", 
    23     :schema_type => "Product", 
     23    :schema_type => XSD::QName.new(NsC_002, "Product"), 
    2424    :schema_element => [ 
    2525      ["id", ["SOAP::SOAPInt", XSD::QName.new(nil, "id")]], 
     
    3737  EncodedRegistry.register( 
    3838    :class => WSDL::RAA::Owner, 
    39     :schema_ns => "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", 
    40     :schema_type => "Owner", 
     39    :schema_type => XSD::QName.new(NsC_002, "Owner"), 
    4140    :schema_element => [ 
    4241      ["id", ["SOAP::SOAPInt", XSD::QName.new(nil, "id")]], 
     
    4847  EncodedRegistry.register( 
    4948    :class => WSDL::RAA::Info, 
    50     :schema_ns => "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", 
    51     :schema_type => "Info", 
     49    :schema_type => XSD::QName.new(NsC_002, "Info"), 
    5250    :schema_element => [ 
    5351      ["category", ["WSDL::RAA::Category", XSD::QName.new(nil, "category")]], 
     
    6361    ::SOAP::SOAPArray, 
    6462    ::SOAP::Mapping::EncodedRegistry::TypedArrayFactory, 
    65     { :type => XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Info") } 
     63    { :type => XSD::QName.new(NsC_002, "Info") } 
    6664  ) 
    6765 
     
    7068    ::SOAP::SOAPArray, 
    7169    ::SOAP::Mapping::EncodedRegistry::TypedArrayFactory, 
    72     { :type => XSD::QName.new("http://www.w3.org/2001/XMLSchema", "string") } 
     70    { :type => XSD::QName.new(NsXMLSchema, "string") } 
    7371  ) 
    7472 
    7573  LiteralRegistry.register( 
    7674    :class => WSDL::RAA::Category, 
    77     :schema_ns => "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", 
    78     :schema_type => "Category", 
     75    :schema_type => XSD::QName.new(NsC_002, "Category"), 
    7976    :schema_qualified => false, 
    8077    :schema_element => [ 
     
    8683  LiteralRegistry.register( 
    8784    :class => WSDL::RAA::Product, 
    88     :schema_ns => "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", 
    89     :schema_type => "Product", 
     85    :schema_type => XSD::QName.new(NsC_002, "Product"), 
    9086    :schema_qualified => false, 
    9187    :schema_element => [ 
     
    104100  LiteralRegistry.register( 
    105101    :class => WSDL::RAA::Owner, 
    106     :schema_ns => "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", 
    107     :schema_type => "Owner", 
     102    :schema_type => XSD::QName.new(NsC_002, "Owner"), 
    108103    :schema_qualified => false, 
    109104    :schema_element => [ 
     
    116111  LiteralRegistry.register( 
    117112    :class => WSDL::RAA::Info, 
    118     :schema_ns => "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", 
    119     :schema_type => "Info", 
     113    :schema_type => XSD::QName.new(NsC_002, "Info"), 
    120114    :schema_qualified => false, 
    121115    :schema_element => [ 
     
    130124  LiteralRegistry.register( 
    131125    :class => WSDL::RAA::InfoArray, 
    132     :schema_ns => "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", 
    133     :schema_type => "InfoArray", 
     126    :schema_type => XSD::QName.new(NsC_002, "InfoArray"), 
    134127    :schema_element => [ 
    135128      ["item", ["WSDL::RAA::Info", XSD::QName.new(nil, "item")], [0, nil]] 
     
    139132  LiteralRegistry.register( 
    140133    :class => WSDL::RAA::StringArray, 
    141     :schema_ns => "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", 
    142     :schema_type => "StringArray", 
     134    :schema_type => XSD::QName.new(NsC_002, "StringArray"), 
    143135    :schema_element => [ 
    144136      ["item", ["String", XSD::QName.new(nil, "item")], [0, nil]] 
  • trunk/test/wsdl/ref/expectedProduct.rb

    r1915 r1934  
    11require 'xsd/qname' 
    22 
    3 module WSDL::Ref 
     3module WSDL; module Ref 
    44 
    55 
     
    240240 
    241241 
    242 end 
     242end; end 
  • trunk/test/xsd/xsd2ruby/expected_mysample.rb

    r1891 r1934  
    11require 'xsd/qname' 
    22 
    3 module XSD::XSD2Ruby 
     3module XSD; module XSD2Ruby 
    44 
    55 
     
    6363 
    6464 
    65 end 
     65end; end