summaryrefslogtreecommitdiff
path: root/lib/soap/mapping/rubytypeFactory.rb
diff options
context:
space:
mode:
authornahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-05-22 13:20:28 +0000
committernahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-05-22 13:20:28 +0000
commit991d0c409cc6b1d916330a32a9624aef808176a4 (patch)
tree5e2cc150dc84ab3f6f64685ec7f54e6b2077eae7 /lib/soap/mapping/rubytypeFactory.rb
parent15b7d439885f4aa97e0f508ef485cadab4b23577 (diff)
* lib/{soap,wsdl,xsd}, test/{soap,wsdl,xsd}: imported soap4r/1.5.4.
== SOAP client and server == === for both client side and server side === * improved document/literal service support. style(rpc,document)/use(encoding, literal) combination are all supported. for the detail about combination, see test/soap/test_style.rb. * let WSDLEncodedRegistry#soap2obj map SOAP/OM to Ruby according to WSDL as well as obj2soap. closes #70. * let SOAP::Mapping::Object handle XML attribute for doc/lit service. you can set/get XML attribute via accessor methods which as a name 'xmlattr_' prefixed (<foo name="bar"/> -> Foo#xmlattr_name). === client side === * WSDLDriver capitalized name operation bug fixed. from 1.5.3-ruby1.8.2, operation which has capitalized name (such as KeywordSearchRequest in AWS) is defined as a method having uncapitalized name. (converted with GenSupport.safemethodname to handle operation name 'foo-bar'). it introduced serious incompatibility; in the past, it was defined as a capitalized. define capitalized method as well under that circumstance. * added new factory interface 'WSDLDriverFactory#create_rpc_driver' to create RPC::Driver, not WSDLDriver (RPC::Driver and WSDLDriver are merged). 'WSDLDriverFactory#create_driver' still creates WSDLDriver for compatibility but it warns that the method is deprecated. please use create_rpc_driver instead of create_driver. * allow to use an URI object as an endpoint_url even with net/http, not http-access2. === server side === * added mod_ruby support to SOAP::CGIStub. rename a CGI script server.cgi to server.rb and let mod_ruby's RubyHandler handles the script. CGIStub detects if it's running under mod_ruby environment or not. * added fcgi support to SOAP::CGIStub. see the sample at sample/soap/calc/server.fcgi. (almost same as server.cgi but has fcgi handler at the bottom.) * allow to return a SOAPFault object to respond customized SOAP fault. * added the interface 'generate_explicit_type' for server side (CGIStub, HTTPServer). call 'self.generate_explicit_type = true' if you want to return simplified XML even if it's rpc/encoded service. == WSDL == === WSDL definition === * improved XML Schema support such as extension, restriction, simpleType, complexType + simpleContent, ref, length, import, include. * reduced "unknown element/attribute" warnings (warn only 1 time for each QName). * importing XSD file at schemaLocation with xsd:import. === code generation from WSDL === * generator crashed when there's '-' in defined element/attribute name. * added ApacheMap WSDL definition. * sample/{soap,wsdl}: removed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@8502 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/soap/mapping/rubytypeFactory.rb')
-rw-r--r--lib/soap/mapping/rubytypeFactory.rb41
1 files changed, 32 insertions, 9 deletions
diff --git a/lib/soap/mapping/rubytypeFactory.rb b/lib/soap/mapping/rubytypeFactory.rb
index 6266148b55..61c21d8b20 100644
--- a/lib/soap/mapping/rubytypeFactory.rb
+++ b/lib/soap/mapping/rubytypeFactory.rb
@@ -1,5 +1,5 @@
# SOAP4R - Ruby type mapping factory.
-# Copyright (C) 2000, 2001, 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+# Copyright (C) 2000-2003, 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
# redistribute it and/or modify it under the same terms of Ruby's license;
@@ -168,7 +168,7 @@ class RubytypeFactory < Factory
return nil
end
if obj.to_s[0] == ?#
- raise TypeError.new("can't dump anonymous class #{ obj }")
+ raise TypeError.new("can't dump anonymous class #{obj}")
end
param = SOAPStruct.new(TYPE_CLASS)
mark_marshalled_obj(obj, param)
@@ -179,7 +179,7 @@ class RubytypeFactory < Factory
return nil
end
if obj.to_s[0] == ?#
- raise TypeError.new("can't dump anonymous module #{ obj }")
+ raise TypeError.new("can't dump anonymous module #{obj}")
end
param = SOAPStruct.new(TYPE_MODULE)
mark_marshalled_obj(obj, param)
@@ -222,7 +222,12 @@ class RubytypeFactory < Factory
when ::SOAP::Mapping::Object
param = SOAPStruct.new(XSD::AnyTypeName)
mark_marshalled_obj(obj, param)
- addiv2soapattr(param, obj, map)
+ obj.__xmlele.each do |key, value|
+ param.add(key.name, Mapping._obj2soap(value, map))
+ end
+ obj.__xmlattr.each do |key, value|
+ param.extraattr[key] = value
+ end
when ::Exception
typestr = Mapping.name2elename(obj.class.to_s)
param = SOAPStruct.new(XSD::QName.new(RubyTypeNamespace, typestr))
@@ -258,12 +263,12 @@ private
def unknownobj2soap(soap_class, obj, info, map)
if obj.class.name.empty?
- raise TypeError.new("can't dump anonymous class #{ obj }")
+ raise TypeError.new("can't dump anonymous class #{obj}")
end
singleton_class = class << obj; self; end
if !singleton_methods_true(obj).empty? or
!singleton_class.instance_variables.empty?
- raise TypeError.new("singleton can't be dumped #{ obj }")
+ raise TypeError.new("singleton can't be dumped #{obj}")
end
if !(singleton_class.ancestors - obj.class.ancestors).empty?
typestr = Mapping.name2elename(obj.class.to_s)
@@ -378,7 +383,11 @@ private
obj = klass.new
mark_unmarshalled_obj(node, obj)
node.each do |name, value|
- obj.__soap_set_property(name, Mapping._soap2obj(value, map))
+ obj.__add_xmlele_value(XSD::QName.new(nil, name),
+ Mapping._soap2obj(value, map))
+ end
+ unless node.extraattr.empty?
+ obj.instance_variable_set('@__xmlattr', node.extraattr)
end
return true, obj
else
@@ -387,7 +396,12 @@ private
end
def unknowntype2obj(node, info, map)
- if node.is_a?(SOAPStruct)
+ case node
+ when SOAPBasetype
+ return true, node.data
+ when SOAPArray
+ return @array_factory.soap2obj(Array, node, info, map)
+ when SOAPStruct
obj = unknownstruct2obj(node, info, map)
return true, obj if obj
if !@allow_untyped_struct
@@ -406,6 +420,9 @@ private
end
typestr = Mapping.elename2name(node.type.name)
klass = Mapping.class_from_name(typestr)
+ if klass.nil? and @allow_untyped_struct
+ klass = Mapping.class_from_name(typestr, true) # lenient
+ end
if klass.nil?
return nil
end
@@ -414,7 +431,13 @@ private
end
klass_type = Mapping.class2qname(klass)
return nil unless node.type.match(klass_type)
- obj = Mapping.create_empty_object(klass)
+ obj = nil
+ begin
+ obj = Mapping.create_empty_object(klass)
+ rescue
+ # type name "data" tries Data.new which raises TypeError
+ nil
+ end
mark_unmarshalled_obj(node, obj)
setiv2obj(obj, node, map)
obj