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

Changeset 1830

Show
Ignore:
Timestamp:
06/05/07 00:21:54 (1 year ago)
Author:
nahi
Message:
  • abstract return type definition causes illegal marshalling/unmarshalling. [1805] unintentionally changed schema definition detection order. closes #352.
Files:

Legend:

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

    r1824 r1830  
    4949  # node should be a SOAPElement 
    5050  def soap2obj(node, obj_class = nil) 
    51     # obj_class is given when rpc/literal service.  but ignored for now. 
    5251    begin 
    53       return any2obj(node
     52      return any2obj(node, obj_class
    5453    rescue MappingError 
    5554    end 
     
    7372    if obj.is_a?(SOAP::Mapping::Object) 
    7473      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) 
    7578    elsif definition = schema_definition_from_elename(qname) 
    76       ele = stubobj2soap(obj, qname, definition) 
    77     elsif definition = schema_definition_from_class(obj.class) 
    7879      ele = stubobj2soap(obj, qname, definition) 
    7980    else 
     
    190191      definition = schema_definition_from_class(obj_class) 
    191192    else 
    192       definition = schema_definition_from_elename(node.elename) 
     193      if node.is_a?(::SOAP::SOAPStruct) 
     194        definition = find_node_definition(node) 
     195      else 
     196        definition = schema_definition_from_elename(node.elename) 
     197      end 
    193198      if definition 
    194199        obj_class = definition.class_for 
  • trunk/lib/soap/mapping/mapping.rb

    r1827 r1830  
    396396 
    397397  def self.schema_definition_classdef(klass) 
    398     if definition = Thread.current[:SOAPMapping][:SchemaDefinition][klass] 
    399       return definition 
     398    if Thread.current[:SOAPMapping][:SchemaDefinition].key?(klass) 
     399      return Thread.current[:SOAPMapping][:SchemaDefinition][klass] 
    400400    end 
    401401    ns = schema_ns_definition(klass) 
  • trunk/lib/soap/mapping/registry.rb

    r1824 r1830  
    208208 
    209209  def find_node_definition(node) 
    210     schema_definition_from_elename(node.elename) || 
    211       schema_definition_from_type(node.type) || 
     210    schema_definition_from_type(node.type) || 
     211      schema_definition_from_elename(node.elename) || 
    212212      find_schema_definition(node.elename.name) || 
    213213      find_schema_definition(node.type.name) 
  • trunk/test/wsdl/abstract/abstract.wsdl

    r1772 r1830  
    2323      </complexType> 
    2424 
     25      <element name="Author" type="tns:Author"/> 
    2526      <complexType abstract="true" name="Author"> 
    2627        <sequence> 
     
    9091  </wsdl:message> 
    9192 
     93  <wsdl:message name="echoLiteralRequest"> 
     94    <wsdl:part name="author" element="tns:Author"/> 
     95  </wsdl:message> 
     96 
     97  <wsdl:message name="echoLiteralResponse"> 
     98    <wsdl:part name="return" element="tns:Author"/> 
     99  </wsdl:message> 
     100 
    92101  <wsdl:message name="echoDerivedRequest"> 
    93102    <wsdl:part name="parameter" type="tns:BaseClass"/> 
     
    104113    </wsdl:operation> 
    105114 
     115    <wsdl:operation name="echoLiteral"> 
     116      <wsdl:input message="tns:echoLiteralRequest"/> 
     117      <wsdl:output message="tns:echoLiteralResponse"/> 
     118    </wsdl:operation> 
     119 
    106120    <wsdl:operation name="echoDerived"> 
    107121      <wsdl:input message="tns:echoDerivedRequest" name="echoDerivedRequest"/> 
     
    113127    type="tns:AbstractService"> 
    114128 
    115     <wsdlsoap:binding style="rpc" 
    116       transport="http://schemas.xmlsoap.org/soap/http"/> 
     129    <wsdlsoap:binding transport="http://schemas.xmlsoap.org/soap/http"/> 
    117130 
    118131    <wsdl:operation name="echo"> 
    119       <wsdlsoap:operation soapAction=""/> 
     132      <wsdlsoap:operation style="rpc" soapAction=""/> 
    120133      <wsdl:input name="echoRequest"> 
    121134        <wsdlsoap:body 
     
    130143    </wsdl:operation> 
    131144 
     145    <wsdl:operation name="echoLiteral"> 
     146      <wsdlsoap:operation style="document" soapAction=""/> 
     147      <wsdl:input name="echoLiteralRequest"> 
     148        <wsdlsoap:body namespace="urn:www.example.org:abstract" use="literal"/> 
     149      </wsdl:input> 
     150      <wsdl:output name="echoLiteralResponse"> 
     151        <wsdlsoap:body namespace="urn:www.example.org:abstract" use="literal"/> 
     152      </wsdl:output> 
     153    </wsdl:operation> 
     154 
    132155    <wsdl:operation name="echoDerived"> 
    133       <wsdlsoap:operation soapAction=""/> 
     156      <wsdlsoap:operation style="rpc" soapAction=""/> 
    134157      <wsdl:input name="echoDerivedRequest"> 
    135158        <wsdlsoap:body 
  • trunk/test/wsdl/abstract/test_abstract.rb

    r1794 r1830  
    1515      add_rpc_method(self, 'echo', 'name', 'author') 
    1616      add_rpc_method(self, 'echoDerived', 'parameter') 
     17      add_document_operation( 
     18        self, 
     19        "", 
     20        "echoLiteral", 
     21        [ ["in", "author", ["::SOAP::SOAPElement", "urn:www.example.org:abstract", "Author"]], 
     22          ["out", "return", ["::SOAP::SOAPElement", "urn:www.example.org:abstract", "Book"]] ], 
     23        { :request_style =>  :document, :request_use =>  :literal, 
     24          :response_style => :document, :response_use => :literal, 
     25          :faults => {} } 
     26      ) 
    1727      self.mapping_registry = AbstractMappingRegistry::EncodedRegistry 
     28      self.literal_mapping_registry = AbstractMappingRegistry::LiteralRegistry 
    1829    end 
    1930   
    2031    def echo(name, author) 
    2132      Book.new(name, author) 
     33    end 
     34 
     35    def echoLiteral(author) 
     36      author 
    2237    end 
    2338 
     
    109124    assert_equal(author.lastname, ret.author.lastname) 
    110125    assert_equal(author.userid, ret.author.userid) 
    111  
     126    # 
    112127    author = NonUserAuthor.new("first", "last", "nonuserid") 
    113128    ret = @client.echo("book2", author) 
     
    116131    assert_equal(author.lastname, ret.author.lastname) 
    117132    assert_equal(author.nonuserid, ret.author.nonuserid) 
     133  end 
     134 
     135  def test_literal_stub 
     136    @client = AbstractService.new("http://localhost:#{Port}/") 
     137    @client.wiredump_dev = STDERR if $DEBUG 
     138    author = NonUserAuthor.new("first", "last", "nonuserid") 
     139    ret = @client.echoLiteral(author) 
     140    assert_equal(author.firstname, ret.firstname) 
     141    assert_equal(author.lastname, ret.lastname) 
     142    assert_equal(author.nonuserid, ret.nonuserid) 
    118143  end 
    119144 
  • trunk/test/wsdl/any/expectedService.rb

    r1790 r1830  
    1414      { :request_style =>  :document, :request_use =>  :literal, 
    1515        :response_style => :document, :response_use => :literal, 
     16        :faults => {} } 
     17    ], 
     18    [ XSD::QName.new("urn:example.com:echo", "echoAny"), 
     19      "urn:example.com:echoAny", 
     20      "echoAny", 
     21      [ ["retval", "echoany_return", [nil]] ], 
     22      { :request_style =>  :rpc, :request_use =>  :encoded, 
     23        :response_style => :rpc, :response_use => :encoded, 
    1624        :faults => {} } 
    1725    ], 
  • trunk/test/wsdl/rpc/test_rpc_lit.rb

    r1810 r1830  
    355355    result = drv.echoNestedStruct(SOAPStructStruct.new("str", 1, 1.0, SOAPStruct.new("str", 1, 1.0)))[0] 
    356356    assert_equal('str', result.varString) 
    357     assert_equal('1', result.varInt) 
    358     assert_equal('+1', result.varFloat) 
     357    assert_equal(1, result.varInt) 
     358    assert_equal(1.0, result.varFloat) 
    359359    assert_equal('str', result.structItem.varString) 
    360360    assert_equal(1, result.structItem.varInt) 
     
    370370    # response contains only 1 part. 
    371371    result = drv.echoNestedStruct(SOAPStructStruct.new("str", nil, 1.0, SOAPStruct.new("str", ::SOAP::SOAPNil.new, 1.0)))[0] 
    372     assert(!result.respond_to?(:varInt)) 
     372    assert(result.respond_to?(:varInt)) 
    373373    assert(result.respond_to?(:varString)) 
    374374    assert_equal(ECHO_NESTED_STRUCT_REQUEST_NIL, parse_requestxml(str),