From 42bca643c3ec41782d519c7676383f8f71e67a7a Mon Sep 17 00:00:00 2001 From: nahi Date: Fri, 28 Nov 2003 05:53:16 +0000 Subject: * lib/soap/streamHandler.rb: drop unused http parameters. * lib/soap/encodingstyle/soapHandler.rb, lib/soap/mapping/factory.rb, lib/soap/mapping/mapping.rb, lib/soap/mapping/registry.rb, lib/wsdl/soap/complexType.rb: ApacheSOAP's map support was broken under WSDL dynanic client environment. fixed. * test/wsdl/raa/*: add tests. * lib/xsd/datatypes.rb: dateTime precision bug fix (at least, I hope.) bug of soap4r. XSDDateTimeImple.to_time passed a Float to Time.local/Time.gm as an usec, and NUM2LONG(rb_num2long for Float) causes rounding error. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5045 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 18 ++++++ MANIFEST | 3 +- lib/soap/encodingstyle/soapHandler.rb | 10 ++-- lib/soap/mapping/factory.rb | 15 +++-- lib/soap/mapping/mapping.rb | 3 +- lib/soap/mapping/registry.rb | 26 +++------ lib/soap/streamHandler.rb | 6 -- lib/wsdl/soap/complexType.rb | 32 +++++++---- lib/xsd/datatypes.rb | 60 ++++++++++++++++---- sample/wsdl/amazon/wsdlDriver.rb | 1 + test/soap/marshal/test_marshal.rb | 2 +- test/soap/test_basetype.rb | 4 ++ test/wsdl/raa/RAA.rb | 15 +---- test/wsdl/raa/RAAServant.rb | 99 ++++++++++++++++++++++++++++++++ test/wsdl/raa/RAAService.rb | 101 +++++++++++++++++++++++++++++++++ test/wsdl/raa/README.txt | 5 +- test/wsdl/raa/server.rb | 104 ---------------------------------- test/wsdl/raa/test_raa.rb | 6 +- test/xsd/test_xsd.rb | 5 ++ 19 files changed, 338 insertions(+), 177 deletions(-) create mode 100644 test/wsdl/raa/RAAServant.rb create mode 100644 test/wsdl/raa/RAAService.rb delete mode 100644 test/wsdl/raa/server.rb diff --git a/ChangeLog b/ChangeLog index 0345050f0b..4641b7fa37 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +Fri Nov 28 14:41:52 2003 NAKAMURA, Hiroshi + + * lib/soap/streamHandler.rb: drop unused http parameters. + + * lib/soap/encodingstyle/soapHandler.rb, lib/soap/mapping/factory.rb, + lib/soap/mapping/mapping.rb, lib/soap/mapping/registry.rb, + lib/wsdl/soap/complexType.rb: ApacheSOAP's map support was broken + under WSDL dynanic client environment. fixed. + + * test/wsdl/raa/*: add tests. + + * lib/xsd/datatypes.rb: dateTime precision bug fix (at least, I hope.) + bug of soap4r. XSDDateTimeImple.to_time passed a Float to + Time.local/Time.gm as an usec, and NUM2LONG(rb_num2long for Float) + causes rounding error. + + * test/soap/test_basetype.rb, test/xsd/test_xsd.rb: add tests. + Fri Nov 28 04:15:24 2003 Nobuyoshi Nakada * eval.c (method_arity): used wrong Proc object. [ruby-talk:86504] diff --git a/MANIFEST b/MANIFEST index ca20c90fc0..3e2dbe5ffe 100644 --- a/MANIFEST +++ b/MANIFEST @@ -731,8 +731,9 @@ test/wsdl/axisArray/test_axisarray.rb test/wsdl/emptycomplextype.wsdl test/wsdl/raa/RAA.rb test/wsdl/raa/README.txt +test/wsdl/raa/RAAServant.rb +test/wsdl/raa/RAAService.rb test/wsdl/raa/raa.wsdl -test/wsdl/raa/server.rb test/wsdl/raa/test_raa.rb test/wsdl/test_emptycomplextype.rb test/xsd/test_xmlschemaparser.rb diff --git a/lib/soap/encodingstyle/soapHandler.rb b/lib/soap/encodingstyle/soapHandler.rb index 51780f5520..1f359bef4e 100644 --- a/lib/soap/encodingstyle/soapHandler.rb +++ b/lib/soap/encodingstyle/soapHandler.rb @@ -162,8 +162,6 @@ class SOAPHandler < Handler o = SOAPReference.decode(elename, href) @refpool << o elsif @decode_typemap - # to parse multi-ref element with decode_tag_by_type. - # && (parent.node.class != SOAPBody || @is_first_top_ele) o = decode_tag_by_wsdl(ns, elename, type, parent.node, arytype, extraattr) else o = decode_tag_by_type(ns, elename, type, parent.node, arytype, extraattr) @@ -333,6 +331,7 @@ private def decode_tag_by_wsdl(ns, elename, typestr, parent, arytypestr, extraattr) o = nil + # should branch by root attribute? if parent.class == SOAPBody if @is_first_top_ele # Unqualified name is allowed here. @@ -363,11 +362,12 @@ private extraattr) end - # parent.definedtype is nil means the parent is SOAPUnknown. SOAPUnknown is - # generated by decode_tag_by_type when its type is anyType. + # parent.definedtype == nil means the parent is SOAPUnknown. SOAPUnknown + # is generated by decode_tag_by_type when its type is anyType. parenttype = parent.definedtype || @decode_typemap[parent.type] unless parenttype - raise EncodingStyleError.new("Unknown type '#{ parent.type }'.") + return decode_tag_by_type(ns, elename, typestr, parent, arytypestr, + extraattr) end definedtype_name = parenttype.child_type(elename) diff --git a/lib/soap/mapping/factory.rb b/lib/soap/mapping/factory.rb index 509fe369c4..f181773687 100644 --- a/lib/soap/mapping/factory.rb +++ b/lib/soap/mapping/factory.rb @@ -356,14 +356,21 @@ class HashFactory_ < Factory unless node.type == MapQName return false end - if node.key?('default') + if node.class == SOAPStruct and node.key?('default') return false end obj = create_empty_object(obj_class) mark_unmarshalled_obj(node, obj) - node.each do |key, value| - obj[Mapping._soap2obj(value['key'], map)] = - Mapping._soap2obj(value['value'], map) + if node.class == SOAPStruct + node.each do |key, value| + obj[Mapping._soap2obj(value['key'], map)] = + Mapping._soap2obj(value['value'], map) + end + else + node.each do |value| + obj[Mapping._soap2obj(value['key'], map)] = + Mapping._soap2obj(value['value'], map) + end end return true, obj end diff --git a/lib/soap/mapping/mapping.rb b/lib/soap/mapping/mapping.rb index 32be9839c8..4b68b811fc 100644 --- a/lib/soap/mapping/mapping.rb +++ b/lib/soap/mapping/mapping.rb @@ -77,9 +77,10 @@ module Mapping end if detail.is_a?(Mapping::SOAPException) begin + remote_backtrace = detail.to_e.backtrace raise detail.to_e rescue Exception => e2 - detail.set_backtrace(e2) + e2.set_backtrace(remote_backtrace + e2.backtrace) raise end else diff --git a/lib/soap/mapping/registry.rb b/lib/soap/mapping/registry.rb index 51ad939d99..46a04e368f 100644 --- a/lib/soap/mapping/registry.rb +++ b/lib/soap/mapping/registry.rb @@ -34,11 +34,9 @@ RubyIVarName = XSD::QName.new(RubyTypeInstanceNamespace, 'ivars') # Inner class to pass an exception. class SOAPException; include Marshallable - attr_reader :excn_type_name, :message, :backtrace, :cause + attr_reader :excn_type_name, :cause def initialize(e) @excn_type_name = Mapping.name2elename(e.class.to_s) - @message = e.message - @backtrace = e.backtrace @cause = e end @@ -50,25 +48,15 @@ class SOAPException; include Marshallable klass = Mapping.class_from_name( Mapping.elename2name(@excn_type_name.to_s)) if klass.nil? - raise RuntimeError.new(@message) + raise RuntimeError.new(@cause.message) end unless klass <= ::Exception raise NameError.new end - obj = klass.new(@message) + obj = klass.new(@cause.message) obj.extend(::SOAP::Mapping::MappedException) obj end - - def set_backtrace(e) - e.set_backtrace( - if @backtrace.is_a?(Array) - @backtrace - else - [@backtrace.inspect] - end - ) - end end @@ -238,10 +226,12 @@ class Registry [::String, ::SOAP::SOAPGMonth, BasetypeFactory], [::String, ::SOAP::SOAPQName, BasetypeFactory], + [::Hash, ::SOAP::SOAPArray, HashFactory], + [::Hash, ::SOAP::SOAPStruct, HashFactory], + [::Array, ::SOAP::SOAPArray, ArrayFactory, {:derived_class => true}], - [::Hash, ::SOAP::SOAPStruct, HashFactory], [::SOAP::Mapping::SOAPException, ::SOAP::SOAPStruct, TypedStructFactory, {:type => XSD::QName.new(RubyCustomTypeNamespace, "SOAPException")}], @@ -282,10 +272,12 @@ class Registry [::String, ::SOAP::SOAPGMonth, BasetypeFactory], [::String, ::SOAP::SOAPQName, BasetypeFactory], + [::Hash, ::SOAP::SOAPArray, HashFactory], + [::Hash, ::SOAP::SOAPStruct, HashFactory], + # Does not allow Array's subclass here. [::Array, ::SOAP::SOAPArray, ArrayFactory], - [::Hash, ::SOAP::SOAPStruct, HashFactory], [::SOAP::Mapping::SOAPException, ::SOAP::SOAPStruct, TypedStructFactory, {:type => XSD::QName.new(RubyCustomTypeNamespace, "SOAPException")}], diff --git a/lib/soap/streamHandler.rb b/lib/soap/streamHandler.rb index 7dcb2d62d6..c5c0661455 100644 --- a/lib/soap/streamHandler.rb +++ b/lib/soap/streamHandler.rb @@ -82,9 +82,6 @@ public attr_reader :client NofRetry = 10 # [times] - ConnectTimeout = 20 # [sec] - SendTimeout = 60 # [sec] - ReceiveTimeout = 60 # [sec] def initialize(endpoint_url, proxy = nil, charset = nil) super(endpoint_url) @@ -93,9 +90,6 @@ public @wiredump_dev = nil # Set an IO to get wiredump. @wiredump_file_base = nil @client = Client.new(@proxy, "SOAP4R/#{ Version }") - @client.session_manager.connect_timeout = ConnectTimeout - @client.session_manager.send_timeout = SendTimeout - @client.session_manager.receive_timeout = ReceiveTimeout end def inspect diff --git a/lib/wsdl/soap/complexType.rb b/lib/wsdl/soap/complexType.rb index e9818faa9a..34fc18f1a4 100644 --- a/lib/wsdl/soap/complexType.rb +++ b/lib/wsdl/soap/complexType.rb @@ -48,13 +48,22 @@ class ComplexType < Info end def child_defined_complextype(name) - unless compoundtype == :TYPE_STRUCT - raise RuntimeError.new("Assert: not for struct") - end - unless ele = find_element(name) - if name.namespace.nil? - ele = find_element_by_name(name.name) + ele = nil + case compoundtype + when :TYPE_STRUCT + unless ele = find_element(name) + if name.namespace.nil? + ele = find_element_by_name(name.name) + end end + when :TYPE_ARRAY + if content.elements.size == 1 + ele = content.elements[0] + else + raise RuntimeError.new("Assert: must not reach.") + end + else + raise RuntimeError.new("Assert: Not implemented.") end unless ele raise RuntimeError.new("Cannot find #{name} as a children of #{@name}.") @@ -83,10 +92,13 @@ class ComplexType < Info private def content_arytype - arytype = find_arytype - ns = arytype.namespace - name = arytype.name.sub(/\[(?:,)*\]$/, '') - XSD::QName.new(ns, name) + if arytype = find_arytype + ns = arytype.namespace + name = arytype.name.sub(/\[(?:,)*\]$/, '') + XSD::QName.new(ns, name) + else + nil + end end end diff --git a/lib/xsd/datatypes.rb b/lib/xsd/datatypes.rb index ca4ef15576..f318e612b1 100644 --- a/lib/xsd/datatypes.rb +++ b/lib/xsd/datatypes.rb @@ -162,7 +162,6 @@ class XSDString < XSDAnySimpleType def initialize(value = nil) super() @type = Type - @encoding = nil set(value) if value end @@ -254,6 +253,7 @@ private end @data = _to_s + @data.freeze end # 0.0 -> 0; right? @@ -440,6 +440,7 @@ private @min = $7.to_i @sec = $8 ? XSDDecimal.new($8) : 0 @data = _to_s + @data.freeze end def _to_s @@ -476,11 +477,11 @@ module XSDDateTimeImpl begin if @data.offset * SecInDay == Time.now.utc_offset d = @data - usec = (d.sec_fraction * SecInDay * 1000000).to_f + usec = (d.sec_fraction * SecInDay * 1000000).round Time.local(d.year, d.month, d.mday, d.hour, d.min, d.sec, usec) else d = @data.newof - usec = (d.sec_fraction * SecInDay * 1000000).to_f + usec = (d.sec_fraction * SecInDay * 1000000).round Time.gm(d.year, d.month, d.mday, d.hour, d.min, d.sec, usec) end rescue ArgumentError @@ -516,6 +517,7 @@ module XSDDateTimeImpl end def _set(t) + set_datetime_init(t) if (t.is_a?(Date)) @data = t elsif (t.is_a?(Time)) @@ -541,11 +543,16 @@ class XSDDateTime < XSDAnySimpleType def initialize(value = nil) super() @type = Type + @secfrac = nil set(value) if value end private + def set_datetime_init(t) + @secfrac = nil + end + def set_str(t) /^([+\-]?\d{4,})-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d(?:\.(\d*))?)(Z|(?:[+\-]\d\d:\d\d)?)?$/ =~ t.to_s.strip unless Regexp.last_match @@ -568,6 +575,7 @@ private zonestr = $8 @data = DateTime.civil(year, mon, mday, hour, min, sec, tz2of(zonestr)) + @secfrac = secfrac if secfrac diffday = secfrac.to_i.to_r / (10 ** secfrac.size) / SecInDay @@ -588,10 +596,11 @@ private s = format('%.4d-%02d-%02dT%02d:%02d:%02d', year, @data.mon, @data.mday, @data.hour, @data.min, @data.sec) if @data.sec_fraction.nonzero? - fr = @data.sec_fraction * SecInDay - shiftsize = fr.denominator.to_s.size + 1 - fr_s = (fr * (10 ** shiftsize)).to_i.to_s - s << '.' << '0' * (shiftsize - fr_s.size) << fr_s.sub(/0+$/, '') + if @secfrac + s << ".#{ @secfrac }" + else + s << sprintf("%.16f", (@data.sec_fraction * SecInDay).to_f).sub(/^0/, '').sub(/0*$/, '') + end end add_tz(s) end @@ -604,11 +613,16 @@ class XSDTime < XSDAnySimpleType def initialize(value = nil) super() @type = Type + @secfrac = nil set(value) if value end private + def set_datetime_init(t) + @secfrac = nil + end + def set_str(t) /^(\d\d):(\d\d):(\d\d(?:\.(\d*))?)(Z|(?:([+\-])(\d\d):(\d\d))?)?$/ =~ t.to_s.strip unless Regexp.last_match @@ -622,19 +636,22 @@ private zonestr = $5 @data = DateTime.civil(1, 1, 1, hour, min, sec, tz2of(zonestr)) + @secfrac = secfrac if secfrac - @data += secfrac.to_i.to_r / (10 ** secfrac.size) / SecInDay + diffday = secfrac.to_i.to_r / (10 ** secfrac.size) / SecInDay + @data += diffday end end def _to_s s = format('%02d:%02d:%02d', @data.hour, @data.min, @data.sec) if @data.sec_fraction.nonzero? - fr = @data.sec_fraction * SecInDay - shiftsize = fr.denominator.to_s.size + 1 - fr_s = (fr * (10 ** shiftsize)).to_i.to_s - s << '.' << '0' * (shiftsize - fr_s.size) << fr_s.sub(/0+$/, '') + if @secfrac + s << ".#{ @secfrac }" + else + s << sprintf("%.16f", (@data.sec_fraction * SecInDay).to_f).sub(/^0/, '').sub(/0*$/, '') + end end add_tz(s) end @@ -652,6 +669,9 @@ class XSDDate < XSDAnySimpleType private + def set_datetime_init(t) + end + def set_str(t) /^([+\-]?\d{4,})-(\d\d)-(\d\d)(Z|(?:([+\-])(\d\d):(\d\d))?)?$/ =~ t.to_s.strip unless Regexp.last_match @@ -688,6 +708,9 @@ class XSDGYearMonth < XSDAnySimpleType private + def set_datetime_init(t) + end + def set_str(t) /^([+\-]?\d{4,})-(\d\d)(Z|(?:([+\-])(\d\d):(\d\d))?)?$/ =~ t.to_s.strip unless Regexp.last_match @@ -723,6 +746,9 @@ class XSDGYear < XSDAnySimpleType private + def set_datetime_init(t) + end + def set_str(t) /^([+\-]?\d{4,})(Z|(?:([+\-])(\d\d):(\d\d))?)?$/ =~ t.to_s.strip unless Regexp.last_match @@ -757,6 +783,9 @@ class XSDGMonthDay < XSDAnySimpleType private + def set_datetime_init(t) + end + def set_str(t) /^(\d\d)-(\d\d)(Z|(?:[+\-]\d\d:\d\d)?)?$/ =~ t.to_s.strip unless Regexp.last_match @@ -788,6 +817,9 @@ class XSDGDay < XSDAnySimpleType private + def set_datetime_init(t) + end + def set_str(t) /^(\d\d)(Z|(?:[+\-]\d\d:\d\d)?)?$/ =~ t.to_s.strip unless Regexp.last_match @@ -818,6 +850,9 @@ class XSDGMonth < XSDAnySimpleType private + def set_datetime_init(t) + end + def set_str(t) /^(\d\d)(Z|(?:[+\-]\d\d:\d\d)?)?$/ =~ t.to_s.strip unless Regexp.last_match @@ -935,6 +970,7 @@ private @prefix = $1 @localpart = $2 @data = _to_s + @data.freeze end def _to_s diff --git a/sample/wsdl/amazon/wsdlDriver.rb b/sample/wsdl/amazon/wsdlDriver.rb index 6b2dce376b..e62a9a65b3 100644 --- a/sample/wsdl/amazon/wsdlDriver.rb +++ b/sample/wsdl/amazon/wsdlDriver.rb @@ -38,6 +38,7 @@ AMAZON_WSDL = 'http://soap.amazon.com/schemas3/AmazonWebServices.wsdl' amazon = SOAP::WSDLDriverFactory.new(AMAZON_WSDL).create_driver p "WSDL loaded" amazon.generate_explicit_type = true +amazon.mandatorycharset = 'utf-8' # AWS should fix this bug. #amazon.wiredump_dev = STDERR # Show sales rank. diff --git a/test/soap/marshal/test_marshal.rb b/test/soap/marshal/test_marshal.rb index 9ae08c68d8..9d5b706d41 100644 --- a/test/soap/marshal/test_marshal.rb +++ b/test/soap/marshal/test_marshal.rb @@ -369,7 +369,7 @@ module MarshalTestLib class MyTime < Time; def initialize(v, *args) super(*args); @v = v; end end def test_time # once there was a bug caused by usec overflow. try a little harder. - 10.times do + 100.times do t = Time.now marshal_equal(t, t.usec.to_s) end diff --git a/test/soap/test_basetype.rb b/test/soap/test_basetype.rb index 0125f80505..a00f0f549c 100644 --- a/test/soap/test_basetype.rb +++ b/test/soap/test_basetype.rb @@ -351,6 +351,8 @@ class TestSOAP < Test::Unit::TestCase "2002-12-31T23:59:59-00:01", "2002-12-31T23:59:59-23:59", "2002-12-31T23:59:59.00000000000000000001+13:30", + "2002-12-31T23:59:59.51375Z", + "2002-12-31T23:59:59.51345+12:34", "-2002-05-18T16:52:20Z", "-4711-12-31T23:59:59Z", "-4713-01-01T12:00:00Z", @@ -414,6 +416,8 @@ class TestSOAP < Test::Unit::TestCase "23:59:59-00:01", "23:59:59-23:59", "23:59:59.00000000000000000001+13:30", + "23:59:59.51375Z", + "23:59:59.51375+12:34", "23:59:59+00:01", ] targets.each do |str| diff --git a/test/wsdl/raa/RAA.rb b/test/wsdl/raa/RAA.rb index 32b88bd26a..aff0525480 100644 --- a/test/wsdl/raa/RAA.rb +++ b/test/wsdl/raa/RAA.rb @@ -235,20 +235,9 @@ class StringArray < Array end # http://xml.apache.org/xml-soap -class Map +class Map < Array + # Contents type should be dumped here... @@schema_type = "Map" @@schema_ns = "http://xml.apache.org/xml-soap" - - def item - @item - end - - def item=(value) - @item = value - end - - def initialize(item = nil) - @item = item - end end diff --git a/test/wsdl/raa/RAAServant.rb b/test/wsdl/raa/RAAServant.rb new file mode 100644 index 0000000000..68380f8e48 --- /dev/null +++ b/test/wsdl/raa/RAAServant.rb @@ -0,0 +1,99 @@ +class RAABaseServicePortType + # SYNOPSIS + # getAllListings + # + # ARGS + # N/A + # + # RETURNS + # return StringArray - {http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/}StringArray + # + # RAISES + # (undefined) + # + def getAllListings + #raise NotImplementedError.new + ["ruby", "soap4r"] + end + + # SYNOPSIS + # getProductTree + # + # ARGS + # N/A + # + # RETURNS + # return Map - {http://xml.apache.org/xml-soap}Map + # + # RAISES + # (undefined) + # + def getProductTree + raise NotImplementedError.new + end + + # SYNOPSIS + # getInfoFromCategory(category) + # + # ARGS + # category Category - {http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/}Category + # + # RETURNS + # return InfoArray - {http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/}InfoArray + # + # RAISES + # (undefined) + # + def getInfoFromCategory(category) + raise NotImplementedError.new + end + + # SYNOPSIS + # getModifiedInfoSince(timeInstant) + # + # ARGS + # timeInstant - {http://www.w3.org/2001/XMLSchema}dateTime + # + # RETURNS + # return InfoArray - {http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/}InfoArray + # + # RAISES + # (undefined) + # + def getModifiedInfoSince(timeInstant) + raise NotImplementedError.new + end + + # SYNOPSIS + # getInfoFromName(productName) + # + # ARGS + # productName - {http://www.w3.org/2001/XMLSchema}string + # + # RETURNS + # return Info - {http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/}Info + # + # RAISES + # (undefined) + # + def getInfoFromName(productName) + raise NotImplementedError.new + end + + # SYNOPSIS + # getInfoFromOwnerId(ownerId) + # + # ARGS + # ownerId - {http://www.w3.org/2001/XMLSchema}int + # + # RETURNS + # return InfoArray - {http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/}InfoArray + # + # RAISES + # (undefined) + # + def getInfoFromOwnerId(ownerId) + raise NotImplementedError.new + end +end + diff --git a/test/wsdl/raa/RAAService.rb b/test/wsdl/raa/RAAService.rb new file mode 100644 index 0000000000..42cdfaea47 --- /dev/null +++ b/test/wsdl/raa/RAAService.rb @@ -0,0 +1,101 @@ +#!/usr/bin/env ruby +require 'RAAServant.rb' + +require 'soap/rpc/standaloneServer' + +class RAABaseServicePortType + MappingRegistry = SOAP::Mapping::Registry.new + + MappingRegistry.set( + StringArray, + ::SOAP::SOAPArray, + ::SOAP::Mapping::Registry::TypedArrayFactory, + { :type => XSD::QName.new("http://www.w3.org/2001/XMLSchema", "string") } + ) + MappingRegistry.set( + Map, + ::SOAP::SOAPArray, + ::SOAP::Mapping::Registry::TypedArrayFactory, + { :type => XSD::QName.new("http://www.w3.org/2001/XMLSchema", "anyType") } + ) + MappingRegistry.set( + Category, + ::SOAP::SOAPStruct, + ::SOAP::Mapping::Registry::TypedStructFactory, + { :type => XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Category") } + ) + MappingRegistry.set( + InfoArray, + ::SOAP::SOAPArray, + ::SOAP::Mapping::Registry::TypedArrayFactory, + { :type => XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Info") } + ) + MappingRegistry.set( + Info, + ::SOAP::SOAPStruct, + ::SOAP::Mapping::Registry::TypedStructFactory, + { :type => XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Info") } + ) + MappingRegistry.set( + Product, + ::SOAP::SOAPStruct, + ::SOAP::Mapping::Registry::TypedStructFactory, + { :type => XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Product") } + ) + MappingRegistry.set( + Owner, + ::SOAP::SOAPStruct, + ::SOAP::Mapping::Registry::TypedStructFactory, + { :type => XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Owner") } + ) + + + Methods = [ + ["getAllListings", "getAllListings", [ + ["retval", "return", + [::SOAP::SOAPArray, "http://www.w3.org/2001/XMLSchema", "string"]]], "", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"], + ["getProductTree", "getProductTree", [ + ["retval", "return", + [::SOAP::SOAPArray, "http://www.w3.org/2001/XMLSchema", "anyType"]]], "", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"], + ["getInfoFromCategory", "getInfoFromCategory", [ + ["in", "category", + [::SOAP::SOAPStruct, "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Category"]], + ["retval", "return", + [::SOAP::SOAPArray, "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Info"]]], "", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"], + ["getModifiedInfoSince", "getModifiedInfoSince", [ + ["in", "timeInstant", + [SOAP::SOAPDateTime]], + ["retval", "return", + [::SOAP::SOAPArray, "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Info"]]], "", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"], + ["getInfoFromName", "getInfoFromName", [ + ["in", "productName", + [SOAP::SOAPString]], + ["retval", "return", + [::SOAP::SOAPStruct, "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Info"]]], "", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"], + ["getInfoFromOwnerId", "getInfoFromOwnerId", [ + ["in", "ownerId", + [SOAP::SOAPInt]], + ["retval", "return", + [::SOAP::SOAPArray, "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Info"]]], "", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"] + ] +end + +class App < SOAP::RPC::StandaloneServer + def initialize(*arg) + super + + servant = RAABaseServicePortType.new + RAABaseServicePortType::Methods.each do |name_as, name, params, soapaction, namespace| + qname = XSD::QName.new(namespace, name_as) + @soaplet.app_scope_router.add_method(servant, qname, soapaction, + name, params) + end + + self.mapping_registry = RAABaseServicePortType::MappingRegistry + end +end + +# Change listen port. +if $0 == __FILE__ + App.new('app', nil, '0.0.0.0', 10080).start +end diff --git a/test/wsdl/raa/README.txt b/test/wsdl/raa/README.txt index e884db9bb4..efbaf9d87c 100644 --- a/test/wsdl/raa/README.txt +++ b/test/wsdl/raa/README.txt @@ -1,4 +1,7 @@ -server.rb: based on RAAService.rb which is generated with the following command; +RAAServant.rb: based on the file which is generated with the following command; + bin/wsdl2ruby.rb --wsdl raa.wsdl --servant_skelton --force + +RAAService.rb: generated with the following command; bin/wsdl2ruby.rb --wsdl raa.wsdl --standalone_server_stub --force RAA.rb: generated with the following command; diff --git a/test/wsdl/raa/server.rb b/test/wsdl/raa/server.rb deleted file mode 100644 index 95e63dcd31..0000000000 --- a/test/wsdl/raa/server.rb +++ /dev/null @@ -1,104 +0,0 @@ -#!/usr/bin/env ruby -require 'soap/rpc/standaloneServer' -require 'RAA.rb' - -class RAABaseServicePortType - MappingRegistry = SOAP::Mapping::Registry.new - - MappingRegistry.set( - StringArray, - ::SOAP::SOAPArray, - ::SOAP::Mapping::Registry::TypedArrayFactory, - { :type => XSD::QName.new("http://www.w3.org/2001/XMLSchema", "string") } - ) - MappingRegistry.set( - Map, - ::SOAP::SOAPStruct, - ::SOAP::Mapping::Registry::TypedStructFactory, - { :type => XSD::QName.new("http://xml.apache.org/xml-soap", "Map") } - ) - MappingRegistry.set( - Category, - ::SOAP::SOAPStruct, - ::SOAP::Mapping::Registry::TypedStructFactory, - { :type => XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Category") } - ) - MappingRegistry.set( - InfoArray, - ::SOAP::SOAPArray, - ::SOAP::Mapping::Registry::TypedArrayFactory, - { :type => XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Info") } - ) - MappingRegistry.set( - Info, - ::SOAP::SOAPStruct, - ::SOAP::Mapping::Registry::TypedStructFactory, - { :type => XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Info") } - ) - MappingRegistry.set( - Product, - ::SOAP::SOAPStruct, - ::SOAP::Mapping::Registry::TypedStructFactory, - { :type => XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Product") } - ) - MappingRegistry.set( - Owner, - ::SOAP::SOAPStruct, - ::SOAP::Mapping::Registry::TypedStructFactory, - { :type => XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Owner") } - ) - - Methods = [ - ["getAllListings", "getAllListings", [ - ["retval", "return", - [::SOAP::SOAPArray, "http://www.w3.org/2001/XMLSchema", "string"]]], - "", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"], - ["getProductTree", "getProductTree", [ - ["retval", "return", - [::SOAP::SOAPStruct, "http://xml.apache.org/xml-soap", "Map"]]], - "", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"], - ["getInfoFromCategory", "getInfoFromCategory", [ - ["in", "category", - [::SOAP::SOAPStruct, "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Category"]], - ["retval", "return", - [::SOAP::SOAPArray, "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Info"]]], - "", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"], - ["getModifiedInfoSince", "getModifiedInfoSince", [ - ["in", "timeInstant", - [SOAP::SOAPDateTime]], - ["retval", "return", - [::SOAP::SOAPArray, "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Info"]]], - "", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"], - ["getInfoFromName", "getInfoFromName", [ - ["in", "productName", - [SOAP::SOAPString]], - ["retval", "return", - [::SOAP::SOAPStruct, "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Info"]]], - "", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"], - ["getInfoFromOwnerId", "getInfoFromOwnerId", [ - ["in", "ownerId", - [SOAP::SOAPInt]], - ["retval", "return", - [::SOAP::SOAPArray, "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Info"]]], - "", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"] - ] - - def getAllListings - ["ruby", "soap4r"] - end -end - -class RAABaseServiceServer < SOAP::RPC::StandaloneServer - def initialize(*arg) - super - - servant = RAABaseServicePortType.new - RAABaseServicePortType::Methods.each do |name_as, name, params, soapaction, namespace| - qname = XSD::QName.new(namespace, name_as) - @soaplet.app_scope_router.add_method(servant, qname, soapaction, - name, params) - end - - self.mapping_registry = RAABaseServicePortType::MappingRegistry - end -end diff --git a/test/wsdl/raa/test_raa.rb b/test/wsdl/raa/test_raa.rb index f90c6222f4..86452a0b40 100644 --- a/test/wsdl/raa/test_raa.rb +++ b/test/wsdl/raa/test_raa.rb @@ -18,9 +18,11 @@ class TestRAA < Test::Unit::TestCase def setup_server $:.push(DIR) - require File.join(DIR, 'server.rb') + require File.join(DIR, 'RAA.rb') + require File.join(DIR, 'RAAServant.rb') + require File.join(DIR, 'RAAService.rb') $:.delete(DIR) - @server = RAABaseServiceServer.new('RAA server', nil, '0.0.0.0', Port) + @server = App.new('RAA server', nil, '0.0.0.0', Port) @server.level = Logger::Severity::ERROR @t = Thread.new { Thread.current.abort_on_exception = true diff --git a/test/xsd/test_xsd.rb b/test/xsd/test_xsd.rb index 88191bb7f1..9b3a7f0f1f 100644 --- a/test/xsd/test_xsd.rb +++ b/test/xsd/test_xsd.rb @@ -384,6 +384,9 @@ class TestXSD < Test::Unit::TestCase "2002-12-31T23:59:59-00:01", "2002-12-31T23:59:59-23:59", "2002-12-31T23:59:59.00000000000000000001+13:30", + "2002-12-31T23:59:59.5137Z", + "2002-12-31T23:59:59.51375Z", # 411/800 + "2002-12-31T23:59:59.51375+12:34", "-2002-05-18T16:52:20Z", "-4713-01-01T12:00:00Z", "-2002-12-31T23:59:59+00:01", @@ -445,6 +448,8 @@ class TestXSD < Test::Unit::TestCase "23:59:59-00:01", "23:59:59-23:59", "23:59:59.00000000000000000001+13:30", + "23:59:59.51345Z", + "23:59:59.51345+12:34", "23:59:59+00:01", ] targets.each do |str| -- cgit v1.2.3