Class: ActionService::Protocol::Soap::SoapProtocol
- Inherits:
-
AbstractProtocol
- Object
- AbstractProtocol
- ActionService::Protocol::Soap::SoapProtocol
- Defined in:
- lib/action_service/protocol/soap.rb
Overview
:nodoc:
Instance Attribute Summary
Attributes inherited from AbstractProtocol
Class Method Summary collapse
Instance Method Summary collapse
- #marshal_exception(exc) ⇒ Object
- #marshal_response(protocol_request, return_value) ⇒ Object
- #unmarshal_request(protocol_request) ⇒ Object
Methods inherited from AbstractProtocol
Constructor Details
This class inherits a constructor from ActionService::Protocol::AbstractProtocol
Class Method Details
.create_protocol_request(container_class, action_pack_request) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/action_service/protocol/soap.rb', line 40 def self.create_protocol_request(container_class, action_pack_request) soap_action = extract_soap_action(action_pack_request) return nil unless soap_action service_name = action_pack_request.parameters['action'] public_method_name = soap_action.gsub(/^[\/]+/, '').split(/[\/]+/)[-1] content_type = action_pack_request.env['HTTP_CONTENT_TYPE'] content_type ||= 'text/xml' protocol = SoapProtocol.new(container_class) ProtocolRequest.new(protocol, action_pack_request.raw_post, service_name.to_sym, public_method_name, content_type) end |
Instance Method Details
#marshal_exception(exc) ⇒ Object
105 106 107 |
# File 'lib/action_service/protocol/soap.rb', line 105 def marshal_exception(exc) ProtocolResponse.new(self, create_exception_response(exc), 'text/xml') end |
#marshal_response(protocol_request, return_value) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/action_service/protocol/soap.rb', line 78 def marshal_response(protocol_request, return_value) marshal = lambda do |signature| mapping = mapper.lookup(signature[0]) return_value = fixup_array_types(mapping, return_value) signature = signature.map{|x|mapper.lookup(x).ruby_klass} protocol_request.check_parameter_types([return_value], signature) param_def = [['retval', 'return', mapping.registry_mapping]] [param_def, ruby_to_soap(return_value)] end signature = protocol_request.return_signature param_def = nil if signature param_def, return_value = marshal.call(signature) else if protocol_request.checked? param_def, return_value = nil, nil else param_def, return_value = marshal.call([return_value.class]) end end qname = XSD::QName.new(mapper.custom_namespace, protocol_request.public_method_name) response = SOAP::RPC::SOAPMethodResponse.new(qname, param_def) response.retval = return_value unless return_value.nil? ProtocolResponse.new(self, create_response(response), 'text/xml') end |
#unmarshal_request(protocol_request) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/action_service/protocol/soap.rb', line 55 def unmarshal_request(protocol_request) unmarshal = lambda do envelope = SOAP::Processor.unmarshal(protocol_request.raw_body) request = envelope.body.request values = request.collect{|k, v| request[k]} soap_to_ruby_array(values) end signature = protocol_request.signature if signature map_signature_types(signature) values = unmarshal.call signature = signature.map{|x|mapper.lookup(x).ruby_klass} protocol_request.check_parameter_types(values, signature) values else if protocol_request.checked? [] else unmarshal.call end end end |