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" }

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Class Attribute Details

.versionObject

Returns the default SOAP version.



23
24
25
# File 'lib/savon/soap.rb', line 23

def version
  @version
end

Instance Attribute Details

#actionObject



38
39
40
# File 'lib/savon/soap.rb', line 38

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.



60
61
62
# File 'lib/savon/soap.rb', line 60

def body=(value)
  @body = value
end

#headerObject

Returns the SOAP header. Defaults to an empty Hash.



54
55
56
# File 'lib/savon/soap.rb', line 54

def header
  @header ||= {}
end

#inputObject



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

def input
  @input ||= ""
end

#namespacesObject

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



68
69
70
# File 'lib/savon/soap.rb', line 68

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

#wsse=(value) ⇒ Object (writeonly)

Sets the WSSE options.



33
34
35
# File 'lib/savon/soap.rb', line 33

def wsse=(value)
  @wsse = value
end

Instance Method Details

#to_xmlObject

Returns the SOAP envelope XML.



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

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.



78
79
80
# File 'lib/savon/soap.rb', line 78

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

#version=(version) ⇒ Object

Sets the SOAP version.



73
74
75
# File 'lib/savon/soap.rb', line 73

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