Class: Savon::Header

Inherits:
Object
  • Object
show all
Defined in:
lib/savon/header.rb

Overview

Assembles the SOAP Header element of a request envelope and renders it to XML.

A SOAP Header carries a request's out-of-band metadata. This object is responsible for every header block Savon can emit, concatenated in this order:

  1. application headers supplied by the caller (the soap_header option),
  2. the WS-Addressing headers, rendered by Addressing,
  3. the WS-Security header with UsernameToken credentials, a wsu:Timestamp and an XML Signature (OASIS WSS SOAP Message Security 1.1).

WS-Security markup is delegated to Akami and Hash-to-XML conversion to Gyoku.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(globals, effective) ⇒ Header

Returns a new instance of Header.

Parameters:

  • globals (Savon::GlobalOptions)

    client-level options, read for the Gyoku key converter (+:convert_request_keys_to+) and the WS-Addressing toggle (+:use_wsa_headers+)

  • effective (Savon::EffectiveOptions)

    resolves the WSSE, soap_header, soap_action and endpoint values for the request



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/savon/header.rb', line 27

def initialize(globals, effective)
  @gyoku_options  = { key_converter: globals[:convert_request_keys_to] }

  @wsse_auth      = effective.wsse_auth
  @wsse_timestamp = effective.wsse_timestamp
  @wsse_signature = effective.wsse_signature
  @soap_header    = effective.soap_header

  @addressing = build_addressing(globals, effective)
  @header     = build
end

Instance Attribute Details

#gyoku_optionsObject (readonly)

Returns the value of attribute gyoku_options.



39
40
41
# File 'lib/savon/header.rb', line 39

def gyoku_options
  @gyoku_options
end

#wsse_authObject (readonly)

Returns the value of attribute wsse_auth.



39
40
41
# File 'lib/savon/header.rb', line 39

def wsse_auth
  @wsse_auth
end

#wsse_signatureObject (readonly)

Returns the value of attribute wsse_signature.



39
40
41
# File 'lib/savon/header.rb', line 39

def wsse_signature
  @wsse_signature
end

#wsse_timestampObject (readonly)

Returns the value of attribute wsse_timestamp.



39
40
41
# File 'lib/savon/header.rb', line 39

def wsse_timestamp
  @wsse_timestamp
end

Instance Method Details

#attributesHash{String => String}

Returns the XML attributes of the enclosing Header element. Only the WS-Addressing section declares one, the xmlns:wsa prefix.

Returns:

  • (Hash{String => String})


45
46
47
# File 'lib/savon/header.rb', line 45

def attributes
  @addressing.namespace_attributes
end

#empty?Boolean

Returns whether the rendered header is empty, i.e. there is no header content to include in the envelope.

Returns:

  • (Boolean)

    whether the rendered header is empty, i.e. there is no header content to include in the envelope



51
52
53
# File 'lib/savon/header.rb', line 51

def empty?
  @header.empty?
end

#to_sString

Returns the rendered SOAP header XML. The header is built once during construction and cached, so this is a cheap, repeatable read.

Returns:

  • (String)

    the header XML (may be empty)



59
60
61
# File 'lib/savon/header.rb', line 59

def to_s
  @header
end