Class: Savon::SOAP

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

Overview

Savon::SOAP

Represents the SOAP parameters and envelope.

Constant Summary collapse

SOAPNamespace =

SOAP namespaces by SOAP version.

{
  1 => "http://schemas.xmlsoap.org/soap/envelope/",
  2 => "http://www.w3.org/2003/05/soap-envelope"
}
ContentType =

Content-Types by SOAP version.

{ 1 => "text/xml", 2 => "application/soap+xml" }
@@version =

The global SOAP version.

1

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#actionObject



36
37
38
# File 'lib/savon/soap.rb', line 36

def action
  @action ||= ""
end

#body=(value) ⇒ Object (writeonly)

Sets the SOAP body. Expected to be a Hash that can be translated to XML via Hash.to_soap_xml or any other Object responding to to_s.



58
59
60
# File 'lib/savon/soap.rb', line 58

def body=(value)
  @body = value
end

#headerObject

Returns the SOAP header. Defaults to an empty Hash.



52
53
54
# File 'lib/savon/soap.rb', line 52

def header
  @header ||= {}
end

#inputObject



43
44
45
# File 'lib/savon/soap.rb', line 43

def input
  @input ||= ""
end

#namespacesObject

Returns the namespaces. A Hash containing the namespaces (keys) and the corresponding URI’s (values).



66
67
68
# File 'lib/savon/soap.rb', line 66

def namespaces
  @namespaces ||= { "xmlns:env" => SOAPNamespace[version] }
end

#wsse=(value) ⇒ Object (writeonly)

Sets the WSSE options.



31
32
33
# File 'lib/savon/soap.rb', line 31

def wsse=(value)
  @wsse = value
end

Class Method Details

.versionObject

Returns the global SOAP version.



21
22
23
# File 'lib/savon/soap.rb', line 21

def self.version
  @@version
end

.version=(version) ⇒ Object

Sets the global SOAP version.



26
27
28
# File 'lib/savon/soap.rb', line 26

def self.version=(version)
  @@version = version if Savon::SOAPVersions.include? version
end

Instance Method Details

#to_xmlObject

Returns the SOAP envelope XML.



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/savon/soap.rb', line 81

def to_xml
  unless @xml_body
    builder = Builder::XmlMarkup.new

    @xml_body = builder.env :Envelope, namespaces do |xml|
      xml.env(:Header) do
        xml << (header.to_soap_xml rescue header.to_s) + wsse_header
      end
      xml.env(:Body) do
        xml.tag!(:wsdl, *input_array) do
          xml << (@body.to_soap_xml rescue @body.to_s)
        end
      end
    end
  end
  @xml_body
end

#versionObject

Returns the SOAP version. Defaults to the global default.



76
77
78
# File 'lib/savon/soap.rb', line 76

def version
  @version ||= self.class.version
end

#version=(version) ⇒ Object

Sets the SOAP version.



71
72
73
# File 'lib/savon/soap.rb', line 71

def version=(version)
  @version = version if Savon::SOAPVersions.include? version
end