Changeset 1830
- Timestamp:
- 06/05/07 00:21:54 (1 year ago)
- Files:
-
- trunk/lib/soap/mapping/literalregistry.rb (modified) (3 diffs)
- trunk/lib/soap/mapping/mapping.rb (modified) (1 diff)
- trunk/lib/soap/mapping/registry.rb (modified) (1 diff)
- trunk/test/wsdl/abstract/abstract.wsdl (modified) (5 diffs)
- trunk/test/wsdl/abstract/test_abstract.rb (modified) (3 diffs)
- trunk/test/wsdl/any/expectedService.rb (modified) (1 diff)
- trunk/test/wsdl/rpc/test_rpc_lit.rb (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/soap/mapping/literalregistry.rb
r1824 r1830 49 49 # node should be a SOAPElement 50 50 def soap2obj(node, obj_class = nil) 51 # obj_class is given when rpc/literal service. but ignored for now.52 51 begin 53 return any2obj(node )52 return any2obj(node, obj_class) 54 53 rescue MappingError 55 54 end … … 73 72 if obj.is_a?(SOAP::Mapping::Object) 74 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) 75 78 elsif definition = schema_definition_from_elename(qname) 76 ele = stubobj2soap(obj, qname, definition)77 elsif definition = schema_definition_from_class(obj.class)78 79 ele = stubobj2soap(obj, qname, definition) 79 80 else … … 190 191 definition = schema_definition_from_class(obj_class) 191 192 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 193 198 if definition 194 199 obj_class = definition.class_for trunk/lib/soap/mapping/mapping.rb
r1827 r1830 396 396 397 397 def self.schema_definition_classdef(klass) 398 if definition = Thread.current[:SOAPMapping][:SchemaDefinition][klass]399 return definition398 if Thread.current[:SOAPMapping][:SchemaDefinition].key?(klass) 399 return Thread.current[:SOAPMapping][:SchemaDefinition][klass] 400 400 end 401 401 ns = schema_ns_definition(klass) trunk/lib/soap/mapping/registry.rb
r1824 r1830 208 208 209 209 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) || 212 212 find_schema_definition(node.elename.name) || 213 213 find_schema_definition(node.type.name) trunk/test/wsdl/abstract/abstract.wsdl
r1772 r1830 23 23 </complexType> 24 24 25 <element name="Author" type="tns:Author"/> 25 26 <complexType abstract="true" name="Author"> 26 27 <sequence> … … 90 91 </wsdl:message> 91 92 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 92 101 <wsdl:message name="echoDerivedRequest"> 93 102 <wsdl:part name="parameter" type="tns:BaseClass"/> … … 104 113 </wsdl:operation> 105 114 115 <wsdl:operation name="echoLiteral"> 116 <wsdl:input message="tns:echoLiteralRequest"/> 117 <wsdl:output message="tns:echoLiteralResponse"/> 118 </wsdl:operation> 119 106 120 <wsdl:operation name="echoDerived"> 107 121 <wsdl:input message="tns:echoDerivedRequest" name="echoDerivedRequest"/> … … 113 127 type="tns:AbstractService"> 114 128 115 <wsdlsoap:binding style="rpc" 116 transport="http://schemas.xmlsoap.org/soap/http"/> 129 <wsdlsoap:binding transport="http://schemas.xmlsoap.org/soap/http"/> 117 130 118 131 <wsdl:operation name="echo"> 119 <wsdlsoap:operation s oapAction=""/>132 <wsdlsoap:operation style="rpc" soapAction=""/> 120 133 <wsdl:input name="echoRequest"> 121 134 <wsdlsoap:body … … 130 143 </wsdl:operation> 131 144 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 132 155 <wsdl:operation name="echoDerived"> 133 <wsdlsoap:operation s oapAction=""/>156 <wsdlsoap:operation style="rpc" soapAction=""/> 134 157 <wsdl:input name="echoDerivedRequest"> 135 158 <wsdlsoap:body trunk/test/wsdl/abstract/test_abstract.rb
r1794 r1830 15 15 add_rpc_method(self, 'echo', 'name', 'author') 16 16 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 ) 17 27 self.mapping_registry = AbstractMappingRegistry::EncodedRegistry 28 self.literal_mapping_registry = AbstractMappingRegistry::LiteralRegistry 18 29 end 19 30 20 31 def echo(name, author) 21 32 Book.new(name, author) 33 end 34 35 def echoLiteral(author) 36 author 22 37 end 23 38 … … 109 124 assert_equal(author.lastname, ret.author.lastname) 110 125 assert_equal(author.userid, ret.author.userid) 111 126 # 112 127 author = NonUserAuthor.new("first", "last", "nonuserid") 113 128 ret = @client.echo("book2", author) … … 116 131 assert_equal(author.lastname, ret.author.lastname) 117 132 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) 118 143 end 119 144 trunk/test/wsdl/any/expectedService.rb
r1790 r1830 14 14 { :request_style => :document, :request_use => :literal, 15 15 :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, 16 24 :faults => {} } 17 25 ], trunk/test/wsdl/rpc/test_rpc_lit.rb
r1810 r1830 355 355 result = drv.echoNestedStruct(SOAPStructStruct.new("str", 1, 1.0, SOAPStruct.new("str", 1, 1.0)))[0] 356 356 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) 359 359 assert_equal('str', result.structItem.varString) 360 360 assert_equal(1, result.structItem.varInt) … … 370 370 # response contains only 1 part. 371 371 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)) 373 373 assert(result.respond_to?(:varString)) 374 374 assert_equal(ECHO_NESTED_STRUCT_REQUEST_NIL, parse_requestxml(str),