Class: SOAP::Mapping::WSDLLiteralRegistry

Inherits:
Registry show all
Defined in:
lib/soap/mapping/wsdlliteralregistry.rb

Constant Summary

Constants inherited from Registry

Registry::ArrayFactory, Registry::Base64Factory, Registry::BasetypeFactory, Registry::DateTimeFactory, Registry::HashFactory, Registry::RubyOriginalMap, Registry::SOAPBaseMap, Registry::StringFactory, Registry::TypedArrayFactory, Registry::TypedStructFactory, Registry::URIFactory

Instance Attribute Summary collapse

Attributes inherited from Registry

#default_factory

Instance Method Summary collapse

Methods inherited from Registry

#add, #find_mapped_obj_class, #find_mapped_soap_class

Constructor Details

#initialize(definedtypes = XSD::NamedElements::Empty, definedelements = XSD::NamedElements::Empty) ⇒ WSDLLiteralRegistry

Returns a new instance of WSDLLiteralRegistry.


26
27
28
29
30
31
32
33
34
# File 'lib/soap/mapping/wsdlliteralregistry.rb', line 26

def initialize(definedtypes = XSD::NamedElements::Empty,
    definedelements = XSD::NamedElements::Empty)
  @definedtypes = definedtypes
  @definedelements = definedelements
  @excn_handler_obj2soap = nil
  @excn_handler_soap2obj = nil
  @schema_element_cache = {}
  @schema_attribute_cache = {}
end

Instance Attribute Details

#definedelementsObject (readonly)

Returns the value of attribute definedelements


21
22
23
# File 'lib/soap/mapping/wsdlliteralregistry.rb', line 21

def definedelements
  @definedelements
end

#definedtypesObject (readonly)

Returns the value of attribute definedtypes


22
23
24
# File 'lib/soap/mapping/wsdlliteralregistry.rb', line 22

def definedtypes
  @definedtypes
end

#excn_handler_obj2soapObject

Returns the value of attribute excn_handler_obj2soap


23
24
25
# File 'lib/soap/mapping/wsdlliteralregistry.rb', line 23

def excn_handler_obj2soap
  @excn_handler_obj2soap
end

#excn_handler_soap2objObject

Returns the value of attribute excn_handler_soap2obj


24
25
26
# File 'lib/soap/mapping/wsdlliteralregistry.rb', line 24

def excn_handler_soap2obj
  @excn_handler_soap2obj
end

Instance Method Details

#obj2soap(obj, qname) ⇒ Object

Raises:


36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/soap/mapping/wsdlliteralregistry.rb', line 36

def obj2soap(obj, qname)
  soap_obj = nil
  if ele = @definedelements[qname]
    soap_obj = obj2elesoap(obj, ele)
  elsif type = @definedtypes[qname]
    soap_obj = obj2typesoap(obj, type, true)
  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, nil, nil, MAPPING_OPT)
    }
    return soap_obj if soap_obj
  end
  raise MappingError.new("cannot map #{obj.class.name} as #{qname}")
end

#soap2obj(node, obj_class = nil) ⇒ Object

node should be a SOAPElement


56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/soap/mapping/wsdlliteralregistry.rb', line 56

def soap2obj(node, obj_class = nil)
  # obj_class is given when rpc/literal service.  but ignored for now.
  begin
    return any2obj(node)
  rescue MappingError
  end
  if @excn_handler_soap2obj
    begin
      return @excn_handler_soap2obj.call(node) { |yield_node|
   Mapping.soap2obj(yield_node, nil, nil, MAPPING_OPT)
 }
    rescue Exception
    end
  end
  if node.respond_to?(:type)
    raise MappingError.new("cannot map #{node.type.name} to Ruby object")
  else
    raise MappingError.new("cannot map #{node.elename.name} to Ruby object")
  end
end