# File soap/mapping/wsdlencodedregistry.rb, line 28
def initialize(definedtypes = XSD::NamedElements::Empty)
@definedtypes = definedtypes
# @definedelements = definedelements needed?
@excn_handler_obj2soap = nil
@excn_handler_soap2obj = nil
# For mapping AnyType element.
@rubytype_factory = RubytypeFactory.new(
:allow_untyped_struct => true,
:allow_original_mapping => true
)
@schema_element_cache = {}
end
# File soap/mapping/wsdlencodedregistry.rb, line 41
def obj2soap(obj, qname = nil)
soap_obj = nil
if type = @definedtypes[qname]
soap_obj = obj2typesoap(obj, type)
else
soap_obj = any2soap(obj, qname)
end
return soap_obj if soap_obj
if @excn_handler_obj2soap
soap_obj = @excn_handler_obj2soap.call(obj) { |yield_obj|
Mapping._obj2soap(yield_obj, self)
}
return soap_obj if soap_obj
end
if qname
raise MappingError.new("cannot map #{obj.class.name} as #{qname}")
else
raise MappingError.new("cannot map #{obj.class.name} to SOAP/OM")
end
end
map anything for now: must refer WSDL while mapping. [ToDo]
# File soap/mapping/wsdlencodedregistry.rb, line 63
def soap2obj(node, obj_class = nil)
begin
return any2obj(node, obj_class)
rescue MappingError
end
if @excn_handler_soap2obj
begin
return @excn_handler_soap2obj.call(node) { |yield_node|
Mapping._soap2obj(yield_node, self)
}
rescue Exception
end
end
raise MappingError.new("cannot map #{node.type.name} to Ruby object")
end
Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.
If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.
If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.
If you want to help improve the Ruby documentation, please see Improve the docs, or visit Documenting-ruby.org.