Class SOAP::Mapping::WSDLEncodedRegistry
In: soap/mapping/wsdlencodedregistry.rb
Parent: Registry

Methods

new   obj2soap   soap2obj  

Included Modules

TraverseSupport

Constants

MapKeyName = XSD::QName.new(nil, "key")
MapValueName = XSD::QName.new(nil, "value")

Attributes

definedelements  [R] 
definedtypes  [R] 
excn_handler_obj2soap  [RW] 
excn_handler_soap2obj  [RW] 

Public Class methods

[Source]

# 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

Public Instance methods

[Source]

# 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]

[Source]

# 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

[Validate]