Class: SOAP::Mapping::WSDLLiteralRegistry
- 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
-
#definedelements ⇒ Object
readonly
Returns the value of attribute definedelements.
-
#definedtypes ⇒ Object
readonly
Returns the value of attribute definedtypes.
-
#excn_handler_obj2soap ⇒ Object
Returns the value of attribute excn_handler_obj2soap.
-
#excn_handler_soap2obj ⇒ Object
Returns the value of attribute excn_handler_soap2obj.
Attributes inherited from Registry
Instance Method Summary collapse
-
#initialize(definedtypes = XSD::NamedElements::Empty, definedelements = XSD::NamedElements::Empty) ⇒ WSDLLiteralRegistry
constructor
A new instance of WSDLLiteralRegistry.
- #obj2soap(obj, qname) ⇒ Object
-
#soap2obj(node, obj_class = nil) ⇒ Object
node should be a SOAPElement.
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
#definedelements ⇒ Object (readonly)
Returns the value of attribute definedelements
21 22 23 |
# File 'lib/soap/mapping/wsdlliteralregistry.rb', line 21 def definedelements @definedelements end |
#definedtypes ⇒ Object (readonly)
Returns the value of attribute definedtypes
22 23 24 |
# File 'lib/soap/mapping/wsdlliteralregistry.rb', line 22 def definedtypes @definedtypes end |
#excn_handler_obj2soap ⇒ Object
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_soap2obj ⇒ Object
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
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 |