summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authornahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-11-28 05:53:16 +0000
committernahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-11-28 05:53:16 +0000
commit42bca643c3ec41782d519c7676383f8f71e67a7a (patch)
tree3ddde51774247d839f4e12ae0d9af6ff2e84d35b /lib
parenta017b0cc8aea236600d47ff04cd829f84499f414 (diff)
* 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
Diffstat (limited to 'lib')
-rw-r--r--lib/soap/encodingstyle/soapHandler.rb10
-rw-r--r--lib/soap/mapping/factory.rb15
-rw-r--r--lib/soap/mapping/mapping.rb3
-rw-r--r--lib/soap/mapping/registry.rb26
-rw-r--r--lib/soap/streamHandler.rb6
-rw-r--r--lib/wsdl/soap/complexType.rb32
-rw-r--r--lib/xsd/datatypes.rb60
7 files changed, 97 insertions, 55 deletions
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