Class: LolSoap::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/lolsoap/request.rb

Overview

Represents a HTTP request containing a SOAP Envelope

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(envelope) ⇒ Request

Returns a new instance of Request.



7
8
9
10
# File 'lib/lolsoap/request.rb', line 7

def initialize(envelope)
  @envelope    = envelope
  @xml_options = default_xml_options
end

Instance Attribute Details

#envelopeObject (readonly)

Returns the value of attribute envelope.



4
5
6
# File 'lib/lolsoap/request.rb', line 4

def envelope
  @envelope
end

#xml_optionsObject

Returns the value of attribute xml_options.



5
6
7
# File 'lib/lolsoap/request.rb', line 5

def xml_options
  @xml_options
end

Instance Method Details

#body(&block) ⇒ Object

See Also:



13
14
15
# File 'lib/lolsoap/request.rb', line 13

def body(&block)
  envelope.body(&block)
end

#charsetObject

The charset of the request. This is always UTF-8, but it could be overridden in a subclass.



59
60
61
# File 'lib/lolsoap/request.rb', line 59

def charset
  'UTF-8'
end

#contentObject

The content to be sent in the HTTP request



79
80
81
# File 'lib/lolsoap/request.rb', line 79

def content
  @content ||= envelope.to_xml(xml_options)
end

#content_typeObject

The full content type of the request, assembled from the #mime and #charset.



65
66
67
# File 'lib/lolsoap/request.rb', line 65

def content_type
 "#{mime};charset=#{charset}"
end

#header(&block) ⇒ Object

See Also:



18
19
20
# File 'lib/lolsoap/request.rb', line 18

def header(&block)
  envelope.header(&block)
end

#headersObject

Headers that must be set when making the request



70
71
72
73
74
75
76
# File 'lib/lolsoap/request.rb', line 70

def headers
  {
    'Content-Type'   => content_type,
    'Content-Length' => content.bytesize.to_s,
    'SOAPAction'     => envelope.action
  }
end

#input_typeObject

The type of the element sent in the request body



38
39
40
# File 'lib/lolsoap/request.rb', line 38

def input_type
  envelope.input_body_content_type
end

#mimeObject

The MIME type of the request. This is always application/soap+xml, but it could be overridden in a subclass.



49
50
51
52
53
54
55
# File 'lib/lolsoap/request.rb', line 49

def mime
  if soap_version == '1.1'
    'text/xml'
  else
    'application/soap+xml'
  end
end

#output_typeObject

The type of the element that will be received in the response body



43
44
45
# File 'lib/lolsoap/request.rb', line 43

def output_type
  envelope.output_body_content_type
end

#soap_namespaceObject

Namespace used for SOAP envelope tags



23
24
25
# File 'lib/lolsoap/request.rb', line 23

def soap_namespace
  envelope.soap_namespace
end

#soap_versionObject

The SOAP version in use



28
29
30
# File 'lib/lolsoap/request.rb', line 28

def soap_version
  envelope.soap_version
end

#urlObject

URL to be POSTed to



33
34
35
# File 'lib/lolsoap/request.rb', line 33

def url
  envelope.endpoint
end