Changeset 1934
- Timestamp:
- 09/03/07 22:41:04 (9 months ago)
- Files:
-
- trunk/lib/wsdl/soap/classDefCreator.rb (modified) (7 diffs)
- trunk/lib/wsdl/soap/encodedMappingRegistryCreator.rb (modified) (1 diff)
- trunk/lib/wsdl/soap/literalMappingRegistryCreator.rb (modified) (3 diffs)
- trunk/test/wsdl/anonymous/expectedClassDef.rb (modified) (2 diffs)
- trunk/test/wsdl/anonymous/expectedMappingRegistry.rb (modified) (2 diffs)
- trunk/test/wsdl/anonymous/lp.wsdl (modified) (1 diff)
- trunk/test/wsdl/any/expectedEcho.rb (modified) (2 diffs)
- trunk/test/wsdl/group/expectedClassdef.rb (modified) (2 diffs)
- trunk/test/wsdl/raa/expectedClassDef.rb (modified) (5 diffs)
- trunk/test/wsdl/raa/expectedDriver.rb (modified) (3 diffs)
- trunk/test/wsdl/raa/expectedMappingRegistry.rb (modified) (11 diffs)
- trunk/test/wsdl/ref/expectedProduct.rb (modified) (2 diffs)
- trunk/test/xsd/xsd2ruby/expected_mysample.rb (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/wsdl/soap/classDefCreator.rb
r1915 r1934 43 43 def dump(type = nil) 44 44 result = "require 'xsd/qname'\n" 45 # cannot use create_class_name with @modulepath because of multiple classes 45 46 if @modulepath 46 47 result << "\n" 47 result << @modulepath.collect { |ele| "module #{ele}" }.join("; ")48 result << modulepath_split(@modulepath).collect { |ele| "module #{ele}" }.join("; ") 48 49 result << "\n\n" 49 50 end … … 79 80 if @modulepath 80 81 result << "\n\n" 81 result << @modulepath.collect { |ele| "end" }.join("; ")82 result << modulepath_split(@modulepath).collect { |ele| "end" }.join("; ") 82 83 result << "\n" 83 84 end … … 276 277 end 277 278 278 def parse_elements(c, elements, base_namespace, parentmodule )279 def parse_elements(c, elements, base_namespace, parentmodule, as_array = false) 279 280 init_lines = [] 280 281 init_params = [] … … 298 299 if element.anonymous_type? 299 300 inner = create_classdef(element.name, element.local_complextype) 300 inner.comment = "inner class for member: #{name}\n" + inner.comment 301 unless as_array 302 inner.comment = "inner class for member: #{name}\n" + inner.comment 303 end 301 304 c.innermodule << inner 302 305 typebase = parentmodule 303 306 end 304 attrname = safemethodname(name) 305 varname = safevarname(name) 306 c.def_attr(attrname, true, varname) 307 init_lines << "@#{varname} = #{varname}" 308 if element.map_as_array? 309 init_params << "#{varname} = []" 310 else 311 init_params << "#{varname} = nil" 307 unless as_array 308 attrname = safemethodname(name) 309 varname = safevarname(name) 310 c.def_attr(attrname, true, varname) 311 init_lines << "@#{varname} = #{varname}" 312 if element.map_as_array? 313 init_params << "#{varname} = []" 314 else 315 init_params << "#{varname} = nil" 316 end 317 c.comment << "\n #{attrname} - #{create_type_name(element, typebase) || '(any)'}" 312 318 end 313 c.comment << "\n #{attrname} - #{create_type_name(element, typebase) || '(any)'}"314 319 when WSDL::XMLSchema::Sequence 315 320 child_init_lines, child_init_params = 316 parse_elements(c, element.elements, base_namespace, parentmodule )321 parse_elements(c, element.elements, base_namespace, parentmodule, as_array) 317 322 init_lines.concat(child_init_lines) 318 323 init_params.concat(child_init_params) 319 324 when WSDL::XMLSchema::Choice 320 325 child_init_lines, child_init_params = 321 parse_elements(c, element.elements, base_namespace, parentmodule )326 parse_elements(c, element.elements, base_namespace, parentmodule, as_array) 322 327 init_lines.concat(child_init_lines) 323 328 init_params.concat(child_init_params) … … 328 333 end 329 334 child_init_lines, child_init_params = 330 parse_elements(c, element.content.elements, base_namespace, parentmodule )335 parse_elements(c, element.content.elements, base_namespace, parentmodule, as_array) 331 336 init_lines.concat(child_init_lines) 332 337 init_params.concat(child_init_params) … … 367 372 end 368 373 369 def dump_arraydef(qname, complextype)374 def dump_arraydef(qname, typedef) 370 375 classname = create_class_name(qname) 371 376 check_classname(classname) 372 377 c = ClassDef.new(classname, '::Array') 373 378 c.comment = "#{qname}" 379 parse_elements(c, typedef.elements, qname.namespace, classname, true) 374 380 c.dump 375 381 end … … 404 410 result 405 411 end 412 413 def modulepath_split(modulepath) 414 if modulepath.is_a?(::Array) 415 modulepath 416 else 417 modulepath.to_s.split('::') 418 end 419 end 406 420 end 407 421 trunk/lib/wsdl/soap/encodedMappingRegistryCreator.rb
r1915 r1934 66 66 dump_struct_typemap(qname, typedef) 67 67 when :TYPE_ARRAY 68 dump_ array_typemap(qname, typedef)68 dump_encoded_array_typemap(qname, typedef) 69 69 when :TYPE_SIMPLE 70 70 dump_simple_typemap(qname, typedef) 71 71 when :TYPE_MAP 72 # mapped as a general Hash 72 73 nil 73 74 else 74 raise NotImplementedError.new("must not reach here: #{typedef.compoundtype}") 75 raise RuntimeError.new( 76 "unknown kind of complexContent: #{typedef.compoundtype}") 75 77 end 76 78 end 77 79 78 def dump_ array_typemap(qname, typedef)80 def dump_encoded_array_typemap(qname, typedef) 79 81 arytype = typedef.find_arytype || XSD::AnyTypeName 80 82 type = XSD::QName.new(arytype.namespace, arytype.name.sub(/\[(?:,)*\]$/, '')) trunk/lib/wsdl/soap/literalMappingRegistryCreator.rb
r1923 r1934 122 122 123 123 def dump_array_typemap(qname, typedef) 124 @dump_struct_typemap_innerstruct = [] 125 @dump_struct_typemap_innerstruct.unshift( 126 dump_literal_array_typemap(qname, typedef)) 127 @dump_struct_typemap_innerstruct.join("\n") 128 end 129 130 def dump_literal_array_typemap(qname, typedef) 124 131 var = {} 125 132 var[:class] = create_class_name(qname, @modulepath) … … 132 139 var[:schema_type] = qname 133 140 end 141 parentmodule = var[:class] 142 parsed_element = parse_elements(typedef.elements, qname.namespace, 143 parentmodule, nil) 144 if parsed_element.empty? 145 parsed_element = [create_soapenc_array_element_definition(typedef)] 146 end 147 var[:schema_element] = dump_schema_element_definition(parsed_element, 2) 148 assign_const(schema_ns, 'Ns') 149 dump_entry(@varname, var) 150 end 151 152 def create_soapenc_array_element_definition(typedef) 134 153 child_type = typedef.child_type 135 154 child_element = typedef.find_aryelement … … 158 177 child_element_name = DEFAULT_ITEM_NAME 159 178 end 160 parsed_element = [] 161 parsed_element << [child_element_name.name, child_element_name, type, occurrence] 162 var[:schema_element] = dump_schema_element_definition(parsed_element, 2) 163 assign_const(schema_ns, 'Ns') 164 dump_entry(@varname, var) 179 [child_element_name.name, child_element_name, type, occurrence] 165 180 end 166 181 end trunk/test/wsdl/anonymous/expectedClassDef.rb
r1915 r1934 1 1 require 'xsd/qname' 2 2 3 module WSDL ::Anonymous3 module WSDL; module Anonymous 4 4 5 6 # {urn:lp}ExtraInfo 7 class ExtraInfo < ::Array 8 9 # {}Entry 10 # key - SOAP::SOAPString 11 # value - SOAP::SOAPString 12 class Entry 13 attr_accessor :key 14 attr_accessor :value 15 16 def initialize(key = nil, value = nil) 17 @key = key 18 @value = value 19 end 20 end 21 end 5 22 6 23 # {urn:lp}loginResponse … … 55 72 56 73 57 end 74 end; end trunk/test/wsdl/anonymous/expectedMappingRegistry.rb
r1923 r1934 8 8 LiteralRegistry = ::SOAP::Mapping::LiteralRegistry.new 9 9 NsLp = "urn:lp" 10 NsXMLSchema = "http://www.w3.org/2001/XMLSchema" 11 12 EncodedRegistry.set( 13 WSDL::Anonymous::ExtraInfo, 14 ::SOAP::SOAPArray, 15 ::SOAP::Mapping::EncodedRegistry::TypedArrayFactory, 16 { :type => XSD::QName.new(NsXMLSchema, "anyType") } 17 ) 10 18 11 19 EncodedRegistry.register( … … 22 30 :schema_element => [ 23 31 ["sessionID", "SOAP::SOAPString"] 32 ] 33 ) 34 35 LiteralRegistry.register( 36 :class => WSDL::Anonymous::ExtraInfo, 37 :schema_type => XSD::QName.new(NsLp, "ExtraInfo"), 38 :schema_element => [ 39 ["entry", ["WSDL::Anonymous::ExtraInfo::Entry[]", XSD::QName.new(nil, "Entry")], [1, nil]] 40 ] 41 ) 42 43 LiteralRegistry.register( 44 :class => WSDL::Anonymous::ExtraInfo::Entry, 45 :schema_name => XSD::QName.new(nil, "Entry"), 46 :schema_element => [ 47 ["key", ["SOAP::SOAPString", XSD::QName.new(nil, "Key")]], 48 ["value", ["SOAP::SOAPString", XSD::QName.new(nil, "Value")]] 24 49 ] 25 50 ) trunk/test/wsdl/anonymous/lp.wsdl
r1915 r1934 9 9 <types> 10 10 <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:lp"> 11 <complexType name="ExtraInfo"> 12 <annotation> 13 <documentation>Service specific information.</documentation> 14 </annotation> 15 <sequence> 16 <element maxOccurs="unbounded" name="Entry"> 17 <complexType> 18 <sequence> 19 <element name="Key" type="xsd:string"/> 20 <element name="Value" type="xsd:string"/> 21 </sequence> 22 </complexType> 23 </element> 24 </sequence> 25 </complexType> 26 11 27 <element name="login"> 12 28 <complexType> trunk/test/wsdl/any/expectedEcho.rb
r1915 r1934 1 1 require 'xsd/qname' 2 2 3 module WSDL ::Any3 module WSDL; module Any 4 4 5 5 … … 55 55 56 56 57 end 57 end; end trunk/test/wsdl/group/expectedClassdef.rb
r1917 r1934 1 1 require 'xsd/qname' 2 2 3 module WSDL ::Group3 module WSDL; module Group 4 4 5 5 … … 56 56 57 57 58 end 58 end; end trunk/test/wsdl/raa/expectedClassDef.rb
r1933 r1934 1 1 require 'xsd/qname' 2 2 3 module WSDL ::RAA3 module WSDL; module RAA 4 4 5 5 6 6 # {http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/}Category 7 # major - SOAP::SOAPString 8 # minor - SOAP::SOAPString 7 9 class Category 8 10 attr_accessor :major … … 16 18 17 19 # {http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/}Product 20 # id - SOAP::SOAPInt 21 # name - SOAP::SOAPString 22 # short_description - SOAP::SOAPString 23 # version - SOAP::SOAPString 24 # status - SOAP::SOAPString 25 # homepage - SOAP::SOAPAnyURI 26 # download - SOAP::SOAPAnyURI 27 # license - SOAP::SOAPString 28 # description - SOAP::SOAPString 18 29 class Product 19 30 attr_accessor :id … … 41 52 42 53 # {http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/}Owner 54 # id - SOAP::SOAPInt 55 # email - SOAP::SOAPAnyURI 56 # name - SOAP::SOAPString 43 57 class Owner 44 58 attr_accessor :id … … 54 68 55 69 # {http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/}Info 70 # category - WSDL::RAA::Category 71 # product - WSDL::RAA::Product 72 # owner - WSDL::RAA::Owner 73 # created - SOAP::SOAPDateTime 74 # updated - SOAP::SOAPDateTime 56 75 class Info 57 76 attr_accessor :category … … 79 98 80 99 81 end 100 end; end trunk/test/wsdl/raa/expectedDriver.rb
r1933 r1934 1 1 require 'RAA.rb' 2 2 require 'RAAMappingRegistry.rb' 3 require 'soap/rpc/driver' 3 4 4 5 module WSDL::RAA 5 require 'soap/rpc/driver'6 6 7 7 class RAABaseServicePortType < ::SOAP::RPC::Driver 8 8 DefaultEndpointUrl = "http://raa.ruby-lang.org/soap/1.0.2/" 9 NsC_002 = "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/" 9 10 10 11 Methods = [ 11 [ XSD::QName.new( "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "getAllListings"),12 [ XSD::QName.new(NsC_002, "getAllListings"), 12 13 "", 13 14 "getAllListings", 14 [ ["retval", "return", ["WSDL::RAA:: C_String[]", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "StringArray"]] ],15 [ ["retval", "return", ["WSDL::RAA::StringArray", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "StringArray"]] ], 15 16 { :request_style => :rpc, :request_use => :encoded, 16 17 :response_style => :rpc, :response_use => :encoded, 17 18 :faults => {} } 18 19 ], 19 [ XSD::QName.new( "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "getProductTree"),20 [ XSD::QName.new(NsC_002, "getProductTree"), 20 21 "", 21 22 "getProductTree", … … 25 26 :faults => {} } 26 27 ], 27 [ XSD::QName.new( "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "getInfoFromCategory"),28 [ XSD::QName.new(NsC_002, "getInfoFromCategory"), 28 29 "", 29 30 "getInfoFromCategory", 30 31 [ ["in", "category", ["WSDL::RAA::Category", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Category"]], 31 ["retval", "return", ["WSDL::RAA::Info []", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "InfoArray"]] ],32 ["retval", "return", ["WSDL::RAA::InfoArray", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "InfoArray"]] ], 32 33 { :request_style => :rpc, :request_use => :encoded, 33 34 :response_style => :rpc, :response_use => :encoded, 34 35 :faults => {} } 35 36 ], 36 [ XSD::QName.new( "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "getModifiedInfoSince"),37 [ XSD::QName.new(NsC_002, "getModifiedInfoSince"), 37 38 "", 38 39 "getModifiedInfoSince", 39 40 [ ["in", "timeInstant", ["::SOAP::SOAPDateTime"]], 40 ["retval", "return", ["WSDL::RAA::Info []", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "InfoArray"]] ],41 ["retval", "return", ["WSDL::RAA::InfoArray", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "InfoArray"]] ], 41 42 { :request_style => :rpc, :request_use => :encoded, 42 43 :response_style => :rpc, :response_use => :encoded, 43 44 :faults => {} } 44 45 ], 45 [ XSD::QName.new( "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "getInfoFromName"),46 [ XSD::QName.new(NsC_002, "getInfoFromName"), 46 47 "", 47 48 "getInfoFromName", … … 52 53 :faults => {} } 53 54 ], 54 [ XSD::QName.new( "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "getInfoFromOwnerId"),55 [ XSD::QName.new(NsC_002, "getInfoFromOwnerId"), 55 56 "", 56 57 "getInfoFromOwnerId", 57 58 [ ["in", "ownerId", ["::SOAP::SOAPInt"]], 58 ["retval", "return", ["WSDL::RAA::Info []", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "InfoArray"]] ],59 ["retval", "return", ["WSDL::RAA::InfoArray", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "InfoArray"]] ], 59 60 { :request_style => :rpc, :request_use => :encoded, 60 61 :response_style => :rpc, :response_use => :encoded, trunk/test/wsdl/raa/expectedMappingRegistry.rb
r1933 r1934 7 7 EncodedRegistry = ::SOAP::Mapping::EncodedRegistry.new 8 8 LiteralRegistry = ::SOAP::Mapping::LiteralRegistry.new 9 NsC_002 = "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/" 10 NsXMLSchema = "http://www.w3.org/2001/XMLSchema" 9 11 10 12 EncodedRegistry.register( 11 13 :class => WSDL::RAA::Category, 12 :schema_ns => "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", 13 :schema_type => "Category", 14 :schema_type => XSD::QName.new(NsC_002, "Category"), 14 15 :schema_element => [ 15 16 ["major", ["SOAP::SOAPString", XSD::QName.new(nil, "major")]], … … 20 21 EncodedRegistry.register( 21 22 :class => WSDL::RAA::Product, 22 :schema_ns => "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", 23 :schema_type => "Product", 23 :schema_type => XSD::QName.new(NsC_002, "Product"), 24 24 :schema_element => [ 25 25 ["id", ["SOAP::SOAPInt", XSD::QName.new(nil, "id")]], … … 37 37 EncodedRegistry.register( 38 38 :class => WSDL::RAA::Owner, 39 :schema_ns => "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", 40 :schema_type => "Owner", 39 :schema_type => XSD::QName.new(NsC_002, "Owner"), 41 40 :schema_element => [ 42 41 ["id", ["SOAP::SOAPInt", XSD::QName.new(nil, "id")]], … … 48 47 EncodedRegistry.register( 49 48 :class => WSDL::RAA::Info, 50 :schema_ns => "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", 51 :schema_type => "Info", 49 :schema_type => XSD::QName.new(NsC_002, "Info"), 52 50 :schema_element => [ 53 51 ["category", ["WSDL::RAA::Category", XSD::QName.new(nil, "category")]], … … 63 61 ::SOAP::SOAPArray, 64 62 ::SOAP::Mapping::EncodedRegistry::TypedArrayFactory, 65 { :type => XSD::QName.new( "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Info") }63 { :type => XSD::QName.new(NsC_002, "Info") } 66 64 ) 67 65 … … 70 68 ::SOAP::SOAPArray, 71 69 ::SOAP::Mapping::EncodedRegistry::TypedArrayFactory, 72 { :type => XSD::QName.new( "http://www.w3.org/2001/XMLSchema", "string") }70 { :type => XSD::QName.new(NsXMLSchema, "string") } 73 71 ) 74 72 75 73 LiteralRegistry.register( 76 74 :class => WSDL::RAA::Category, 77 :schema_ns => "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", 78 :schema_type => "Category", 75 :schema_type => XSD::QName.new(NsC_002, "Category"), 79 76 :schema_qualified => false, 80 77 :schema_element => [ … … 86 83 LiteralRegistry.register( 87 84 :class => WSDL::RAA::Product, 88 :schema_ns => "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", 89 :schema_type => "Product", 85 :schema_type => XSD::QName.new(NsC_002, "Product"), 90 86 :schema_qualified => false, 91 87 :schema_element => [ … … 104 100 LiteralRegistry.register( 105 101 :class => WSDL::RAA::Owner, 106 :schema_ns => "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", 107 :schema_type => "Owner", 102 :schema_type => XSD::QName.new(NsC_002, "Owner"), 108 103 :schema_qualified => false, 109 104 :schema_element => [ … … 116 111 LiteralRegistry.register( 117 112 :class => WSDL::RAA::Info, 118 :schema_ns => "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", 119 :schema_type => "Info", 113 :schema_type => XSD::QName.new(NsC_002, "Info"), 120 114 :schema_qualified => false, 121 115 :schema_element => [ … … 130 124 LiteralRegistry.register( 131 125 :class => WSDL::RAA::InfoArray, 132 :schema_ns => "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", 133 :schema_type => "InfoArray", 126 :schema_type => XSD::QName.new(NsC_002, "InfoArray"), 134 127 :schema_element => [ 135 128 ["item", ["WSDL::RAA::Info", XSD::QName.new(nil, "item")], [0, nil]] … … 139 132 LiteralRegistry.register( 140 133 :class => WSDL::RAA::StringArray, 141 :schema_ns => "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", 142 :schema_type => "StringArray", 134 :schema_type => XSD::QName.new(NsC_002, "StringArray"), 143 135 :schema_element => [ 144 136 ["item", ["String", XSD::QName.new(nil, "item")], [0, nil]] trunk/test/wsdl/ref/expectedProduct.rb
r1915 r1934 1 1 require 'xsd/qname' 2 2 3 module WSDL ::Ref3 module WSDL; module Ref 4 4 5 5 … … 240 240 241 241 242 end 242 end; end trunk/test/xsd/xsd2ruby/expected_mysample.rb
r1891 r1934 1 1 require 'xsd/qname' 2 2 3 module XSD ::XSD2Ruby3 module XSD; module XSD2Ruby 4 4 5 5 … … 63 63 64 64 65 end 65 end; end