class Sekken::Operation
Constants
- CONTENT_TYPE
- ENCODING
Attributes
body[RW]
Public: Sets the request body Hash.
encoding[RW]
Public: Accessor for the encoding. Defaults to ‘UTF-8’.
endpoint[RW]
Public: Accessor for the SOAP endpoint.
header[RW]
Public: Sets the request header Hash.
http_headers[W]
Public: Sets the Hash of HTTP headers.
soap_action[RW]
Public: Accessor for the SOAPAction HTTP header.
soap_version[RW]
Public: Accessor for the SOAP version.
xml_envelope[RW]
Public: Sets the request envelope XML
. Use in place of body().
Public Class Methods
new(operation, wsdl, http)
click to toggle source
# File lib/sekken/operation.rb, line 15 def initialize(operation, wsdl, http) @operation = operation @wsdl = wsdl @http = http @endpoint = operation.endpoint @soap_version = operation.soap_version @soap_action = operation.soap_action @encoding = ENCODING end
Public Instance Methods
body_parts()
click to toggle source
Public: Returns the input body parts used to build the request body.
# File lib/sekken/operation.rb, line 76 def body_parts @operation.input.body_parts.inject([]) { |memo, part| memo + part.to_a } end
build()
click to toggle source
Public: Build the request XML
for this operation.
# File lib/sekken/operation.rb, line 81 def build @build ||= Envelope.new(@operation, header, body).to_s end
call()
click to toggle source
Public: Call the operation.
# File lib/sekken/operation.rb, line 89 def call message = (xml_envelope != nil ? xml_envelope : build) raw_response = @http.post(endpoint, http_headers, message) Response.new(raw_response) end
example_body()
click to toggle source
Public: Create an example request body Hash.
# File lib/sekken/operation.rb, line 71 def example_body ExampleMessage.build(@operation.input.body_parts) end
example_header()
click to toggle source
Public: Create an example request header Hash.
# File lib/sekken/operation.rb, line 63 def example_header ExampleMessage.build(@operation.input.header_parts) end
http_headers()
click to toggle source
Public: Returns a Hash of HTTP headers to send.
# File lib/sekken/operation.rb, line 39 def http_headers return @http_headers if @http_headers headers = {} content_type = [ CONTENT_TYPE[soap_version], "charset=#{encoding}" ] case soap_version when '1.1' headers['SOAPAction'] = soap_action.nil? ? '' : %{"#{soap_action}"} when '1.2' content_type << %{action="#{soap_action}"} if soap_action && !soap_action.empty? end headers['Content-Type'] = content_type.join(';') @http_headers = headers end
input_style()
click to toggle source
Public: Returns the input style for this operation.
# File lib/sekken/operation.rb, line 97 def input_style @input_style ||= @operation.input_style end
output_style()
click to toggle source
Public: Returns the output style for this operation.
# File lib/sekken/operation.rb, line 102 def output_style @output_style ||= @operation.output_style end