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

Changeset 1853

Show
Ignore:
Timestamp:
06/18/07 22:24:02 (1 year ago)
Author:
nahi
Message:
  • derived class was marshalled without xsi:type for literal service. closes #361.
Files:

Legend:

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

    r1835 r1853  
    7171    ele = nil 
    7272    if obj.is_a?(SOAP::Mapping::Object) 
    73       ele = mappingobj2soap(obj, qname) 
    74     elsif definition = schema_definition_from_class(obj.class) 
    75       # search with class first.  obj can be an instance of a subclass of 
    76       # defined class. 
    77       ele = stubobj2soap(obj, qname, definition) 
    78     elsif definition = schema_definition_from_elename(qname) 
    79       ele = stubobj2soap(obj, qname, definition) 
    80     else 
    81       ele = anyobj2soap(obj, qname) 
    82     end 
    83     ele 
     73      return mappingobj2soap(obj, qname) 
     74    end 
     75    class_definition = schema_definition_from_class(obj.class) 
     76    elename_definition = schema_definition_from_elename(qname) 
     77    if !class_definition and !elename_definition 
     78      # no definition found 
     79      return anyobj2soap(obj, qname) 
     80    end 
     81    if !class_definition or !elename_definition 
     82      # use found one 
     83      return stubobj2soap(obj, qname, class_definition || elename_definition) 
     84    end 
     85    # found both: 
     86    if class_definition.class_for == elename_definition.class_for 
     87      # if two definitions are for the same class, give qname a priority. 
     88      return stubobj2soap(obj, qname, elename_definition) 
     89    end 
     90    # it should be a derived class 
     91    return stubobj2soap(obj, qname, class_definition) 
    8492  end 
    8593 
  • trunk/lib/soap/mapping/registry.rb

    r1830 r1853  
    186186    obj_class = definition[:class] 
    187187    definition = Mapping.create_schema_definition(obj_class, definition) 
    188     @class_schema_definition[obj_class] = definition 
     188    # give complexType definition a priority explicitly 
     189    if !@class_schema_definition[obj_class] or definition.type 
     190      @class_schema_definition[obj_class] = definition 
     191    end 
    189192    if definition.elename 
    190193      @elename_schema_definition[definition.elename] = definition 
  • trunk/test/wsdl/qualified/test_unqualified.rb

    r1805 r1853  
    100100</env:Envelope>] 
    101101 
    102   LOGIN_REQUEST_QUALIFIED_TYPED = 
    103 %q[<?xml version="1.0" encoding="utf-8" ?> 
    104 <env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    105     xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" 
    106     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
    107   <env:Body> 
    108     <n1:login xmlns:n1="urn:lp"> 
    109       <username>NaHi</username> 
    110       <password>passwd</password> 
    111       <timezone>JST</timezone> 
    112     </n1:login> 
    113   </env:Body> 
    114 </env:Envelope>] 
    115  
    116102  def test_wsdl 
    117103    wsdl = File.join(DIR, 'lp.wsdl') 
     
    139125    @client.wiredump_dev = str = '' 
    140126    @client.login(Login.new('NaHi', 'passwd', 'JST')) 
    141     assert_equal(LOGIN_REQUEST_QUALIFIED_TYPED, parse_requestxml(str)) 
     127    assert_equal(LOGIN_REQUEST_QUALIFIED_UNTYPED, parse_requestxml(str)) 
    142128  end 
    143129