Changeset 1958
- Timestamp:
- 09/13/07 21:06:56 (11 months ago)
- Files:
-
- trunk/lib/soap/baseData.rb (modified) (1 diff)
- trunk/lib/wsdl/soap/encodedMappingRegistryCreator.rb (modified) (2 diffs)
- trunk/lib/wsdl/soap/literalMappingRegistryCreator.rb (modified) (1 diff)
- trunk/lib/wsdl/soap/mappingRegistryCreatorSupport.rb (modified) (4 diffs)
- trunk/test/wsdl/anonymous/expectedMappingRegistry.rb (modified) (2 diffs)
- trunk/test/wsdl/axisArray/axisArray.wsdl (modified) (3 diffs)
- trunk/test/wsdl/axisArray/test_axisarray.rb (modified) (3 diffs)
- trunk/test/wsdl/raa/expectedMappingRegistry.rb (modified) (2 diffs)
- trunk/test/wsdl/rpc/test_rpc.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/soap/baseData.rb
r1947 r1958 159 159 else 160 160 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 161 169 end 162 170 end trunk/lib/wsdl/soap/encodedMappingRegistryCreator.rb
r1954 r1958 67 67 dump_struct_typemap(mpath, qname, typedef) 68 68 when :TYPE_ARRAY 69 dump_ encoded_array_typemap(mpath, qname, typedef)69 dump_array_typemap(mpath, qname, typedef) 70 70 when :TYPE_SIMPLE 71 71 dump_simple_typemap(mpath, qname, typedef) … … 78 78 end 79 79 end 80 81 def dump_encoded_array_typemap(mpath, qname, typedef)82 arytype = typedef.find_arytype || XSD::AnyTypeName83 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 end94 80 end 95 81 trunk/lib/wsdl/soap/literalMappingRegistryCreator.rb
r1954 r1958 120 120 end 121 121 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 end131 132 def dump_literal_array_typemap(mpath, qname, typedef)133 var = {}134 var[:class] = mapped_class_name(qname, mpath)135 schema_ns = qname.namespace136 if typedef.name.nil?137 # local complextype of a element138 var[:schema_name] = qname139 else140 # named complextype141 var[:schema_type] = qname142 end143 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 end148 var[:schema_element] = dump_schema_element_definition(parsed_element, 2)149 assign_const(schema_ns, 'Ns')150 dump_entry(@varname, var)151 end152 153 def create_soapenc_array_element_definition(typedef, mpath)154 child_type = typedef.child_type155 child_element = typedef.find_aryelement156 if child_type == XSD::AnyTypeName157 type = nil158 elsif child_element159 if klass = element_basetype(child_element)160 type = klass.name161 else162 typename = child_element.type || child_element.name163 type = mapped_class_name(typename, mpath)164 end165 elsif child_type166 type = mapped_class_name(child_type, mpath)167 else168 type = nil169 end170 occurrence = [0, nil]171 if child_element and child_element.name172 if child_element.map_as_array?173 type << '[]' if type174 occurrence = [child_element.minoccurs, child_element.maxoccurs]175 end176 child_element_name = child_element.name177 else178 child_element_name = DEFAULT_ITEM_NAME179 end180 [child_element_name.name, child_element_name, type, occurrence]181 end182 122 end 183 123 trunk/lib/wsdl/soap/mappingRegistryCreatorSupport.rb
r1954 r1958 14 14 15 15 16 # requires @defined_const = {}, @dump_ struct_typemap_innerstruct, @modulepath16 # requires @defined_const = {}, @dump_with_inner, @modulepath 17 17 module MappingRegistryCreatorSupport 18 18 include ClassDefCreatorSupport … … 20 20 21 21 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") 26 37 end 27 38 … … 141 152 typebase = @modulepath 142 153 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) 145 156 typebase = mpath 146 157 end … … 290 301 nil 291 302 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 292 356 end 293 357 trunk/test/wsdl/anonymous/expectedMappingRegistry.rb
r1954 r1958 8 8 LiteralRegistry = ::SOAP::Mapping::LiteralRegistry.new 9 9 NsLp = "urn:lp" 10 NsXMLSchema = "http://www.w3.org/2001/XMLSchema"11 10 12 11 EncodedRegistry.register( … … 18 17 ) 19 18 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 ] 25 34 ) 26 35 trunk/test/wsdl/axisArray/axisArray.wsdl
r1520 r1958 22 22 </sequence> 23 23 </complexType> 24 25 <complexType name="MeetingInfo"> 26 <sequence> 27 <element name="meetingId" type="xsd:long"/> 28 </sequence> 29 </complexType> 24 30 </schema> 25 31 </wsdl:types> … … 31 37 </wsdl:message> 32 38 39 <wsdl:message name="getMeetingInfoRequest"/> 40 41 <wsdl:message name="getMeetingInfoResponse"> 42 <wsdl:part name="getMeetingInfoReturn" type="typens:MeetingInfo"/> 43 </wsdl:message> 44 33 45 <wsdl:portType name="ItemListPortType"> 34 46 <wsdl:operation name="listItem"> 35 47 <wsdl:input message="tns:listItemRequest" name="listItemRequest"/> 36 48 <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"/> 37 53 </wsdl:operation> 38 54 </wsdl:portType> … … 43 59 <soap:operation soapAction=""/> 44 60 <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"/> 47 63 </wsdl:input> 48 64 <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"/> 51 78 </wsdl:output> 52 79 </wsdl:operation> trunk/test/wsdl/axisArray/test_axisarray.rb
r1731 r1958 4 4 require 'soap/rpc/element' 5 5 require 'wsdl/importer' 6 require 'itemList.rb' 6 require 'wsdl/soap/wsdl2ruby' 7 require File.join(File.dirname(File.expand_path(__FILE__)), '..', '..', 'testutil.rb') 7 8 8 9 9 10 module WSDL 11 module AxisArray 10 12 11 13 12 14 class TestAxisArray < Test::Unit::TestCase 15 DIR = File.dirname(File.expand_path(__FILE__)) 16 13 17 def setup 14 18 @xml =<<__EOX__ … … 36 40 </soapenv:Envelope> 37 41 __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') 38 65 end 39 66 40 67 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 43 71 assert_equal(3, ary.size) 44 72 assert_equal("name1", ary[0].name) … … 64 92 assert_equal("name3", ary[2].name) 65 93 end 94 95 XML_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 66 120 end 67 121 68 122 69 123 end 124 end trunk/test/wsdl/raa/expectedMappingRegistry.rb
r1934 r1958 8 8 LiteralRegistry = ::SOAP::Mapping::LiteralRegistry.new 9 9 NsC_002 = "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/" 10 NsXMLSchema = "http://www.w3.org/2001/XMLSchema"11 10 12 11 EncodedRegistry.register( … … 57 56 ) 58 57 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 ] 64 64 ) 65 65 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 ] 71 72 ) 72 73 trunk/test/wsdl/rpc/test_rpc.rb
r1862 r1958 166 166 def test_basetype_stub 167 167 @client = Prefix::Echo_port_type.new("http://localhost:#{Port}/") 168 @client.mapping_registry = Prefix::EchoMappingRegistry::EncodedRegistry169 168 @client.wiredump_dev = STDERR if $DEBUG 170 169