class LolSoap::Envelope

Constants

SOAP_1_1

@private

SOAP_1_2

@private

Attributes

doc[R]
operation[R]
wsdl[R]

Public Class Methods

new(wsdl, operation, doc = Nokogiri::XML::Document.new) click to toggle source
# File lib/lolsoap/envelope.rb, line 14
def initialize(wsdl, operation, doc = Nokogiri::XML::Document.new)
  @wsdl      = wsdl
  @operation = operation
  @doc       = doc

  initialize_doc
end

Public Instance Methods

action() click to toggle source
# File lib/lolsoap/envelope.rb, line 45
def action
  operation.action
end
body(klass = Builder) { |builder| ... } click to toggle source

Build the body of the envelope

@example

env.body do |b|
  b.some 'data'
end
# File lib/lolsoap/envelope.rb, line 28
def body(klass = Builder)
  builder = klass.new(body_content, input_body_content_type)
  yield builder if block_given?
  builder
end
endpoint() click to toggle source
# File lib/lolsoap/envelope.rb, line 41
def endpoint
  wsdl.endpoint
end
header(klass = Builder) { |builder| ... } click to toggle source

Build the header of the envelope

# File lib/lolsoap/envelope.rb, line 35
def header(klass = Builder)
  builder = klass.new(header_content, input_header_content_type)
  yield builder if block_given?
  builder
end
input() click to toggle source
# File lib/lolsoap/envelope.rb, line 49
def input
  operation.input
end
input_body() click to toggle source
# File lib/lolsoap/envelope.rb, line 65
def input_body
  input.body
end
input_body_content() click to toggle source
# File lib/lolsoap/envelope.rb, line 69
def input_body_content
  input_body.content
end
input_body_content_type() click to toggle source
# File lib/lolsoap/envelope.rb, line 73
def input_body_content_type
  input_body.content_type
end
input_header() click to toggle source
# File lib/lolsoap/envelope.rb, line 53
def input_header
  input.header
end
input_header_content() click to toggle source
# File lib/lolsoap/envelope.rb, line 57
def input_header_content
  input_header.content
end
input_header_content_type() click to toggle source
# File lib/lolsoap/envelope.rb, line 61
def input_header_content_type
  input_header.content_type
end
output() click to toggle source
# File lib/lolsoap/envelope.rb, line 77
def output
  operation.output
end
output_body() click to toggle source
# File lib/lolsoap/envelope.rb, line 89
def output_body
  output.body
end
output_body_content() click to toggle source
# File lib/lolsoap/envelope.rb, line 93
def output_body_content
  output_body.content
end
output_body_content_type() click to toggle source
# File lib/lolsoap/envelope.rb, line 97
def output_body_content_type
  output_body.content_type
end
output_header() click to toggle source
# File lib/lolsoap/envelope.rb, line 81
def output_header
  output.header
end
output_header_type() click to toggle source
# File lib/lolsoap/envelope.rb, line 85
def output_header_type
  output_header && output_header.type
end
soap_namespace() click to toggle source
# File lib/lolsoap/envelope.rb, line 109
def soap_namespace
  soap_version == '1.2' ? SOAP_1_2 : SOAP_1_1
end
soap_prefix() click to toggle source
# File lib/lolsoap/envelope.rb, line 105
def soap_prefix
  'soap'
end
soap_version() click to toggle source
# File lib/lolsoap/envelope.rb, line 113
def soap_version
  wsdl.soap_version
end
to_xml(options = {}) click to toggle source
# File lib/lolsoap/envelope.rb, line 101
def to_xml(options = {})
  doc.to_xml(options)
end

Private Instance Methods

body_content() click to toggle source

@private

# File lib/lolsoap/envelope.rb, line 123
def body_content; @body_content; end
header_content() click to toggle source

@private

# File lib/lolsoap/envelope.rb, line 120
def header_content; @header_content; end
initialize_doc() click to toggle source

@private

# File lib/lolsoap/envelope.rb, line 126
def initialize_doc
  doc.root = root = doc.create_element('Envelope')

  namespaces = Hash[wsdl.namespaces.map { |prefix, uri| [prefix, root.add_namespace(prefix, uri)] }]
  namespaces[soap_prefix] = root.add_namespace(soap_prefix, soap_namespace)

  @header = doc.create_element input_header.name
  @body   = doc.create_element input_body.name

  [root, @header, @body].each { |el| el.namespace = namespaces[soap_prefix] }

  if input_header_content
    @header_content = doc.create_element input_header_content.name
    @header_content.namespace = namespaces[input_header_content.prefix]
    @header << @header_content
  else
    @header_content = @header
  end

  if input_body_content
    @body_content = doc.create_element input_body_content.name
    @body_content.namespace = namespaces[input_body_content.prefix]
    @body << @body_content
  else
    @body_content = @body
  end

  root << @header
  root << @body
end