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

Changeset 1958

Show
Ignore:
Timestamp:
09/13/07 21:06:56 (11 months ago)
Author:
nahi
Message:
Files:

Legend:

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

    r1947 r1958  
    159159    else 
    160160      nil 
     161    end 
     162  end 
     163 
     164  # for referenced base type such as a long value from Axis. 
     165  # base2obj requires a node to respond to :data 
     166  def data 
     167    if @obj.respond_to?(:data) 
     168      @obj.data 
    161169    end 
    162170  end 
  • trunk/lib/wsdl/soap/encodedMappingRegistryCreator.rb

    r1954 r1958  
    6767      dump_struct_typemap(mpath, qname, typedef) 
    6868    when :TYPE_ARRAY 
    69       dump_encoded_array_typemap(mpath, qname, typedef) 
     69      dump_array_typemap(mpath, qname, typedef) 
    7070    when :TYPE_SIMPLE 
    7171      dump_simple_typemap(mpath, qname, typedef) 
     
    7878    end 
    7979  end 
    80  
    81   def dump_encoded_array_typemap(mpath, qname, typedef) 
    82     arytype = typedef.find_arytype || XSD::AnyTypeName 
    83     type = XSD::QName.new(arytype.namespace, arytype.name.sub(/\[(?:,)*\]$/, '')) 
    84     assign_const(type.namespace, 'Ns') 
    85     return <<__EOD__ 
    86 #{@varname}.set( 
    87   #{mapped_class_name(qname, mpath)}, 
    88   ::SOAP::SOAPArray, 
    89   ::SOAP::Mapping::EncodedRegistry::TypedArrayFactory, 
    90   { :type => #{dqname(type)} } 
    91 ) 
    92 __EOD__ 
    93   end 
    9480end 
    9581 
  • trunk/lib/wsdl/soap/literalMappingRegistryCreator.rb

    r1954 r1958  
    120120    end 
    121121  end 
    122  
    123   DEFAULT_ITEM_NAME = XSD::QName.new(nil, 'item') 
    124  
    125   def dump_array_typemap(mpath, qname, typedef) 
    126     @dump_struct_typemap_innerstruct = [] 
    127     @dump_struct_typemap_innerstruct.unshift( 
    128       dump_literal_array_typemap(mpath, qname, typedef)) 
    129     @dump_struct_typemap_innerstruct.join("\n") 
    130   end 
    131  
    132   def dump_literal_array_typemap(mpath, qname, typedef) 
    133     var = {} 
    134     var[:class] = mapped_class_name(qname, mpath) 
    135     schema_ns = qname.namespace 
    136     if typedef.name.nil? 
    137       # local complextype of a element 
    138       var[:schema_name] = qname 
    139     else 
    140       # named complextype 
    141       var[:schema_type] = qname 
    142     end 
    143     parsed_element = 
    144       parse_elements(typedef.elements, qname.namespace, var[:class], nil) 
    145     if parsed_element.empty? 
    146       parsed_element = [create_soapenc_array_element_definition(typedef, mpath)] 
    147     end 
    148     var[:schema_element] = dump_schema_element_definition(parsed_element, 2) 
    149     assign_const(schema_ns, 'Ns') 
    150     dump_entry(@varname, var) 
    151   end 
    152  
    153   def create_soapenc_array_element_definition(typedef, mpath) 
    154     child_type = typedef.child_type 
    155     child_element = typedef.find_aryelement 
    156     if child_type == XSD::AnyTypeName 
    157       type = nil 
    158     elsif child_element 
    159       if klass = element_basetype(child_element) 
    160         type = klass.name 
    161       else 
    162         typename = child_element.type || child_element.name 
    163         type = mapped_class_name(typename, mpath) 
    164       end 
    165     elsif child_type 
    166       type = mapped_class_name(child_type, mpath) 
    167     else 
    168       type = nil 
    169     end 
    170     occurrence = [0, nil] 
    171     if child_element and child_element.name 
    172       if child_element.map_as_array? 
    173         type << '[]' if type 
    174         occurrence = [child_element.minoccurs, child_element.maxoccurs] 
    175       end 
    176       child_element_name = child_element.name 
    177     else 
    178       child_element_name = DEFAULT_ITEM_NAME 
    179     end 
    180     [child_element_name.name, child_element_name, type, occurrence] 
    181   end 
    182122end 
    183123 
  • trunk/lib/wsdl/soap/mappingRegistryCreatorSupport.rb

    r1954 r1958  
    1414 
    1515 
    16 # requires @defined_const = {}, @dump_struct_typemap_innerstruct, @modulepath 
     16# requires @defined_const = {}, @dump_with_inner, @modulepath 
    1717module MappingRegistryCreatorSupport 
    1818  include ClassDefCreatorSupport 
     
    2020 
    2121  def dump_struct_typemap(mpath, qname, typedef, as_element = nil, qualified = nil) 
    22     @dump_struct_typemap_innerstruct = [] 
    23     @dump_struct_typemap_innerstruct.unshift( 
    24       dump_complex_typemap(mpath, qname, typedef, as_element, qualified)) 
    25     @dump_struct_typemap_innerstruct.join("\n") 
     22    dump_with_inner { 
     23      dump_complex_typemap(mpath, qname, typedef, as_element, qualified) 
     24    } 
     25  end 
     26 
     27  def dump_array_typemap(mpath, qname, typedef) 
     28    dump_with_inner { 
     29      dump_literal_array_typemap(mpath, qname, typedef) 
     30    } 
     31  end 
     32 
     33  def dump_with_inner 
     34    @dump_with_inner = [] 
     35    @dump_with_inner.unshift(yield) 
     36    @dump_with_inner.join("\n") 
    2637  end 
    2738 
     
    141152        typebase = @modulepath 
    142153        if element.anonymous_type? 
    143           @dump_struct_typemap_innerstruct << dump_complex_typemap( 
    144               mpath, element.name, element.local_complextype, nil, qualified) 
     154          @dump_with_inner << dump_complex_typemap(mpath, element.name, 
     155            element.local_complextype, nil, qualified) 
    145156          typebase = mpath 
    146157        end 
     
    290301    nil 
    291302  end 
     303 
     304  DEFAULT_ITEM_NAME = XSD::QName.new(nil, 'item') 
     305 
     306  def dump_literal_array_typemap(mpath, qname, typedef) 
     307    var = {} 
     308    var[:class] = mapped_class_name(qname, mpath) 
     309    schema_ns = qname.namespace 
     310    if typedef.name.nil? 
     311      # local complextype of a element 
     312      var[:schema_name] = qname 
     313    else 
     314      # named complextype 
     315      var[:schema_type] = qname 
     316    end 
     317    parsed_element = 
     318      parse_elements(typedef.elements, qname.namespace, var[:class], nil) 
     319    if parsed_element.empty? 
     320      parsed_element = [create_soapenc_array_element_definition(typedef, mpath)] 
     321    end 
     322    var[:schema_element] = dump_schema_element_definition(parsed_element, 2) 
     323    assign_const(schema_ns, 'Ns') 
     324    dump_entry(@varname, var) 
     325  end 
     326 
     327  def create_soapenc_array_element_definition(typedef, mpath) 
     328    child_type = typedef.child_type 
     329    child_element = typedef.find_aryelement 
     330    if child_type == XSD::AnyTypeName 
     331      type = nil 
     332    elsif child_element 
     333      if klass = element_basetype(child_element) 
     334        type = klass.name 
     335      else 
     336        typename = child_element.type || child_element.name 
     337        type = mapped_class_name(typename, mpath) 
     338      end 
     339    elsif child_type 
     340      type = mapped_class_name(child_type, mpath) 
     341    else 
     342      type = nil 
     343    end 
     344    occurrence = [0, nil] 
     345    if child_element and child_element.name 
     346      if child_element.map_as_array? 
     347        type << '[]' if type 
     348        occurrence = [child_element.minoccurs, child_element.maxoccurs] 
     349      end 
     350      child_element_name = child_element.name 
     351    else 
     352      child_element_name = DEFAULT_ITEM_NAME 
     353    end 
     354    [child_element_name.name, child_element_name, type, occurrence] 
     355  end 
    292356end 
    293357 
  • trunk/test/wsdl/anonymous/expectedMappingRegistry.rb

    r1954 r1958  
    88  LiteralRegistry = ::SOAP::Mapping::LiteralRegistry.new 
    99  NsLp = "urn:lp" 
    10   NsXMLSchema = "http://www.w3.org/2001/XMLSchema" 
    1110 
    1211  EncodedRegistry.register( 
     
    1817  ) 
    1918 
    20   EncodedRegistry.set( 
    21     WSDL::Anonymous::ExtraInfo, 
    22     ::SOAP::SOAPArray, 
    23     ::SOAP::Mapping::EncodedRegistry::TypedArrayFactory, 
    24     { :type => XSD::QName.new(NsXMLSchema, "anyType") } 
     19  EncodedRegistry.register( 
     20    :class => WSDL::Anonymous::ExtraInfo, 
     21    :schema_type => XSD::QName.new(NsLp, "ExtraInfo"), 
     22    :schema_element => [ 
     23      ["entry", ["WSDL::Anonymous::ExtraInfo::Entry[]", XSD::QName.new(nil, "Entry")], [1, nil]] 
     24    ] 
     25  ) 
     26 
     27  EncodedRegistry.register( 
     28    :class => WSDL::Anonymous::ExtraInfo::Entry, 
     29    :schema_name => XSD::QName.new(nil, "Entry"), 
     30    :schema_element => [ 
     31      ["key", ["SOAP::SOAPString", XSD::QName.new(nil, "Key")]], 
     32      ["value", ["SOAP::SOAPString", XSD::QName.new(nil, "Value")]] 
     33    ] 
    2534  ) 
    2635 
  • trunk/test/wsdl/axisArray/axisArray.wsdl

    r1520 r1958  
    2222        </sequence> 
    2323      </complexType> 
     24 
     25      <complexType name="MeetingInfo"> 
     26        <sequence> 
     27          <element name="meetingId" type="xsd:long"/> 
     28        </sequence> 
     29      </complexType> 
    2430    </schema> 
    2531  </wsdl:types> 
     
    3137  </wsdl:message> 
    3238 
     39  <wsdl:message name="getMeetingInfoRequest"/> 
     40 
     41  <wsdl:message name="getMeetingInfoResponse"> 
     42    <wsdl:part name="getMeetingInfoReturn" type="typens:MeetingInfo"/> 
     43  </wsdl:message> 
     44 
    3345  <wsdl:portType name="ItemListPortType"> 
    3446    <wsdl:operation name="listItem"> 
    3547      <wsdl:input message="tns:listItemRequest" name="listItemRequest"/> 
    3648      <wsdl:output message="tns:listItemResponse" name="listItemResponse"/> 
     49    </wsdl:operation> 
     50    <wsdl:operation name="getMeetingInfo"> 
     51      <wsdl:input name="getMeetingInfoRequest" message="tns:getMeetingInfoRequest"/> 
     52      <wsdl:output name="getMeetingInfoResponse" message="tns:getMeetingInfoResponse"/> 
    3753    </wsdl:operation> 
    3854  </wsdl:portType> 
     
    4359      <soap:operation soapAction=""/> 
    4460      <wsdl:input name="listItemRequest"> 
    45        <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
    46            namespace="urn:jp.gr.jin.rrr.example.itemList" use="encoded"/> 
     61        <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
     62          namespace="urn:jp.gr.jin.rrr.example.itemList" use="encoded"/> 
    4763      </wsdl:input> 
    4864      <wsdl:output name="listItemResponse"> 
    49         <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
    50             namespace="urn:jp.gr.jin.rrr.example.itemList" use="encoded"/> 
     65        <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
     66          namespace="urn:jp.gr.jin.rrr.example.itemList" use="encoded"/> 
     67      </wsdl:output> 
     68    </wsdl:operation> 
     69    <wsdl:operation name="getMeetingInfo"> 
     70      <soap:operation soapAction=""/> 
     71      <wsdl:input name="getMeetingInfoRequest"> 
     72        <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
     73          namespace="urn:jp.gr.jin.rrr.example.itemList"/> 
     74      </wsdl:input> 
     75      <wsdl:output name="getMeetingInfoResponse"> 
     76        <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
     77          namespace="urn:jp.gr.jin.rrr.example.itemList"/> 
    5178      </wsdl:output> 
    5279    </wsdl:operation> 
  • trunk/test/wsdl/axisArray/test_axisarray.rb

    r1731 r1958  
    44require 'soap/rpc/element' 
    55require 'wsdl/importer' 
    6 require 'itemList.rb' 
     6require 'wsdl/soap/wsdl2ruby' 
     7require File.join(File.dirname(File.expand_path(__FILE__)), '..', '..', 'testutil.rb') 
    78 
    89 
    910module WSDL 
     11module AxisArray 
    1012 
    1113 
    1214class TestAxisArray < Test::Unit::TestCase 
     15  DIR = File.dirname(File.expand_path(__FILE__)) 
     16 
    1317  def setup 
    1418    @xml =<<__EOX__ 
     
    3640</soapenv:Envelope> 
    3741__EOX__ 
     42    setup_classdef 
     43  end 
     44 
     45  def teardown 
     46    unless $DEBUG 
     47      File.unlink(pathname('itemList.rb')) 
     48      File.unlink(pathname('itemListMappingRegistry.rb')) 
     49      File.unlink(pathname('itemListDriver.rb')) 
     50    end 
     51  end 
     52 
     53  def setup_classdef 
     54    gen = WSDL::SOAP::WSDL2Ruby.new 
     55    gen.location = pathname("axisArray.wsdl") 
     56    gen.basedir = DIR 
     57    gen.logger.level = Logger::FATAL 
     58    gen.opt['classdef'] = nil 
     59    gen.opt['mapping_registry'] = nil 
     60    gen.opt['module_path'] = self.class.to_s.sub(/::[^:]+$/, '') 
     61    gen.opt['driver'] = nil 
     62    gen.opt['force'] = true 
     63    gen.run 
     64    TestUtil.require(DIR, 'itemListDriver.rb', 'itemList.rb', 'itemListMappingRegistry.rb') 
    3865  end 
    3966 
    4067  def test_by_stub 
    41     header, body = ::SOAP::Processor.unmarshal(@xml) 
    42     ary = ::SOAP::Mapping.soap2obj(body.response) 
     68    driver = ItemListPortType.new 
     69    driver.test_loopback_response << @xml 
     70    ary = driver.listItem 
    4371    assert_equal(3, ary.size) 
    4472    assert_equal("name1", ary[0].name) 
     
    6492    assert_equal("name3", ary[2].name) 
    6593  end 
     94 
     95XML_LONG = <<__XML__ 
     96<?xml version="1.0" encoding="utf-8"?> 
     97<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
     98  <soapenv:Body> 
     99    <ns1:getMeetingInfoResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="urn:jp.gr.jin.rrr.example.itemList"> 
     100      <getMeetingInfoReturn href="#id0"/> 
     101    </ns1:getMeetingInfoResponse> 
     102    <multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns2:MeetingInfo" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="urn:long"> 
     103      <meetingId href="#id11"/> 
     104    </multiRef> 
     105    <multiRef id="id11" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="xsd:long" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">105759347</multiRef> 
     106  </soapenv:Body> 
     107</soapenv:Envelope> 
     108__XML__ 
     109 
     110  def test_multiref_long 
     111    driver = ItemListPortType.new 
     112    driver.test_loopback_response << XML_LONG 
     113    ret = driver.getMeetingInfo 
     114    assert_equal(105759347, ret.meetingId) 
     115  end 
     116 
     117  def pathname(filename) 
     118    File.join(DIR, filename) 
     119  end 
    66120end 
    67121 
    68122 
    69123end 
     124end 
  • trunk/test/wsdl/raa/expectedMappingRegistry.rb

    r1934 r1958  
    88  LiteralRegistry = ::SOAP::Mapping::LiteralRegistry.new 
    99  NsC_002 = "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/" 
    10   NsXMLSchema = "http://www.w3.org/2001/XMLSchema" 
    1110 
    1211  EncodedRegistry.register( 
     
    5756  ) 
    5857 
    59   EncodedRegistry.set( 
    60     WSDL::RAA::InfoArray, 
    61     ::SOAP::SOAPArray, 
    62     ::SOAP::Mapping::EncodedRegistry::TypedArrayFactory, 
    63     { :type => XSD::QName.new(NsC_002, "Info") } 
     58  EncodedRegistry.register( 
     59    :class => WSDL::RAA::InfoArray, 
     60    :schema_type => XSD::QName.new(NsC_002, "InfoArray"), 
     61    :schema_element => [ 
     62      ["item", ["WSDL::RAA::Info", XSD::QName.new(nil, "item")], [0, nil]] 
     63    ] 
    6464  ) 
    6565 
    66   EncodedRegistry.set( 
    67     WSDL::RAA::StringArray, 
    68     ::SOAP::SOAPArray, 
    69     ::SOAP::Mapping::EncodedRegistry::TypedArrayFactory, 
    70     { :type => XSD::QName.new(NsXMLSchema, "string") } 
     66  EncodedRegistry.register( 
     67    :class => WSDL::RAA::StringArray, 
     68    :schema_type => XSD::QName.new(NsC_002, "StringArray"), 
     69    :schema_element => [ 
     70      ["item", ["String", XSD::QName.new(nil, "item")], [0, nil]] 
     71    ] 
    7172  ) 
    7273 
  • trunk/test/wsdl/rpc/test_rpc.rb

    r1862 r1958  
    166166  def test_basetype_stub 
    167167    @client = Prefix::Echo_port_type.new("http://localhost:#{Port}/") 
    168     @client.mapping_registry = Prefix::EchoMappingRegistry::EncodedRegistry 
    169168    @client.wiredump_dev = STDERR if $DEBUG 
    170169