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

Changeset 1942

Show
Ignore:
Timestamp:
09/07/07 21:43:43 (1 year ago)
Author:
nahi
Message:
  • a Driver generated by a WSDLDriverFactory ignored 'xmlattr_*' value in a Hash parameter. closes #414.
Files:

Legend:

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

    r1935 r1942  
    146146    return ele if obj.nil? 
    147147    stubobj2soap_elements(obj, ele, definition.elements) 
    148     if definition.attributes 
    149       definition.attributes.each do |qname, param| 
    150         attrname = XSD::CodeGen::GenSupport.safemethodname( 
    151           'xmlattr_' + qname.name) 
    152         ele.extraattr[qname] = Mapping.get_attribute(obj, attrname) 
    153       end 
    154     end 
     148    add_definedattributes2soap(obj, ele, definition) 
    155149    ele 
    156150  end 
  • trunk/lib/soap/mapping/registry.rb

    r1925 r1942  
    229229   
    230230  def add_attributes2soap(obj, ele) 
    231     definition = Mapping.schema_definition_classdef(obj.class) 
    232     if definition && attributes = definition.attributes 
    233       attributes.each do |qname, param| 
    234         at = Mapping.get_attribute(obj, XSD::CodeGen::GenSupport.safemethodname('xmlattr_' + qname.name)) 
    235         ele.extraattr[qname] = at 
    236       end 
     231    if definition = Mapping.schema_definition_classdef(obj.class) 
     232      add_definedattributes2soap(obj, ele, definition) 
    237233    elsif obj.respond_to?(:__xmlattr) 
    238234      obj.__xmlattr.each do |key, value| 
     
    240236      end 
    241237    end 
     238  end 
     239 
     240  def add_definedattributes2soap(obj, ele, typedef) 
     241    if typedef.attributes 
     242      typedef.attributes.each do |qname, param| 
     243        ele.extraattr[qname] = get_xmlattr_value(obj, qname) 
     244      end 
     245    end 
     246  end 
     247 
     248  def get_xmlattr_value(obj, qname) 
     249    attrname = 'xmlattr_' + qname.name 
     250    value = Mapping.get_attribute(obj, attrname) 
     251    if value.nil? 
     252      attrname = 
     253        XSD::CodeGen::GenSupport.safemethodname('xmlattr_' + qname.name) 
     254      value = Mapping.get_attribute(obj, attrname) 
     255    end 
     256    value 
    242257  end 
    243258 
  • trunk/lib/soap/mapping/wsdlliteralregistry.rb

    r1937 r1942  
    105105    if type.is_a?(::WSDL::XMLSchema::SimpleType) 
    106106      ele = simpleobj2soap(obj, type) 
    107     elsif type.simplecontent 
    108       ele = simpleobj2soap(obj, type.simplecontent) 
    109     else 
    110       ele = complexobj2soap(obj, type) 
    111     end 
    112     add_attributes2soap(obj, ele) 
     107    else # complexType 
     108      if type.simplecontent 
     109        ele = simpleobj2soap(obj, type.simplecontent) 
     110      else 
     111        ele = complexobj2soap(obj, type) 
     112      end 
     113      add_definedattributes2soap(obj, ele, type) 
     114    end 
    113115    ele 
    114116  end 
     
    226228    end 
    227229  end 
     230 
     231  def add_definedattributes2soap(obj, ele, typedef) 
     232    if typedef.attributes 
     233      typedef.attributes.each do |at| 
     234        ele.extraattr[at.name] = get_xmlattr_value(obj, at.name) 
     235      end 
     236    end 
     237  end 
    228238end 
    229239 
  • trunk/test/wsdl/document/test_rpc.rb

    r1805 r1942  
    147147  end 
    148148 
     149  def test_wsdl_with_map 
     150    wsdl = File.join(DIR, 'document.wsdl') 
     151    @client = ::SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver 
     152    @client.endpoint_url = "http://localhost:#{Port}/" 
     153    @client.wiredump_dev = STDOUT if $DEBUG 
     154 
     155    struct1 = { 
     156      :m_string => "mystring1", 
     157      :m_datetime => (now1 = Time.now), 
     158      :xmlattr_m_attr => "myattr1" 
     159    } 
     160    struct2 = { 
     161      "m_string" => "mystring2", 
     162      "m_datetime" => now2 = (Time.now), 
     163      "xmlattr_m_attr" => "myattr2" 
     164    } 
     165    echo = { 
     166      :struct1 => struct1, 
     167      "struct-2" => struct2, 
     168      :xmlattr_attr_string => 'attr_string', 
     169      "xmlattr_attr-int" => 5 
     170    } 
     171    ret = @client.echo(echo) 
     172    # 
     173    now1str = XSD::XSDDateTime.new(now1).to_s 
     174    now2str = XSD::XSDDateTime.new(now2).to_s 
     175    assert_equal("mystring2", ret.struct1.m_string) 
     176    assert_equal(now2str, ret.struct1.m_datetime) 
     177    assert_equal("mystring1", ret.struct_2.m_string) 
     178    assert_equal(now1str, ret.struct_2.m_datetime) 
     179    assert_equal("attr_string", ret.xmlattr_attr_string) 
     180    assert_equal("5", ret.xmlattr_attr_int) 
     181  end 
     182 
    149183  def date2time(date) 
    150184    if date.respond_to?(:to_time)