Class: ActionWebService::Protocol::Soap::SoapProtocol
- Inherits:
-
AbstractProtocol
- Object
- AbstractProtocol
- ActionWebService::Protocol::Soap::SoapProtocol
- Defined in:
- lib/action_web_service/protocol/soap_protocol.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#mapper ⇒ Object
readonly
Returns the value of attribute mapper.
Attributes inherited from AbstractProtocol
Class Method Summary collapse
- .create_protocol_client(api, protocol_name, endpoint_uri, options) ⇒ Object
- .create_protocol_request(container_class, action_pack_request) ⇒ Object
Instance Method Summary collapse
-
#initialize(mapper) ⇒ SoapProtocol
constructor
A new instance of SoapProtocol.
- #marshal_exception(exc) ⇒ Object
- #marshal_response(protocol_request, return_value) ⇒ Object
- #unmarshal_request(protocol_request) ⇒ Object
Constructor Details
#initialize(mapper) ⇒ SoapProtocol
Returns a new instance of SoapProtocol.
42 43 44 |
# File 'lib/action_web_service/protocol/soap_protocol.rb', line 42 def initialize(mapper) @mapper = mapper end |
Instance Attribute Details
#mapper ⇒ Object (readonly)
Returns the value of attribute mapper.
40 41 42 |
# File 'lib/action_web_service/protocol/soap_protocol.rb', line 40 def mapper @mapper end |
Class Method Details
.create_protocol_client(api, protocol_name, endpoint_uri, options) ⇒ Object
61 62 63 64 |
# File 'lib/action_web_service/protocol/soap_protocol.rb', line 61 def self.create_protocol_client(api, protocol_name, endpoint_uri, ) return nil unless protocol_name.to_s.downcase.to_sym == :soap ActionWebService::Client::Soap.new(api, endpoint_uri, ) end |
.create_protocol_request(container_class, action_pack_request) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/action_web_service/protocol/soap_protocol.rb', line 46 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.soap_mapper) 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
116 117 118 |
# File 'lib/action_web_service/protocol/soap_protocol.rb', line 116 def marshal_exception(exc) ProtocolResponse.new(self, create_exception_response(exc), 'text/xml') end |
#marshal_response(protocol_request, return_value) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/action_web_service/protocol/soap_protocol.rb', line 89 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
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/action_web_service/protocol/soap_protocol.rb', line 66 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 |