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

Constructor Details

#initializeSOAP

Initialzes the SOAP object.



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

def initialize
  @builder = Builder::XmlMarkup.new
end

Instance Attribute Details

#actionObject

Returns the SOAP action.



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

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.



91
92
93
# File 'lib/savon/soap.rb', line 91

def body=(value)
  @body = value
end

#endpointObject

Accessor for the SOAP endpoint.



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

def endpoint
  @endpoint
end

#headerObject

Returns the SOAP header. Defaults to an empty Hash.



85
86
87
# File 'lib/savon/soap.rb', line 85

def header
  @header ||= {}
end

#inputObject

Returns the SOAP input.



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

def input
  @input ||= ""
end

#namespacesObject

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



99
100
101
# File 'lib/savon/soap.rb', line 99

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

#wsse=(value) ⇒ Object (writeonly)

Sets the WSSE options.



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

def wsse=(value)
  @wsse = value
end

Class Method Details

.headerObject

Returns the global SOAP header. Defaults to an empty Hash.



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

def self.header
  @@header ||= {}
end

.header=(header) ⇒ Object

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



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

def self.header=(header)
  @@header = header
end

.namespacesObject

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



49
50
51
# File 'lib/savon/soap.rb', line 49

def self.namespaces
  @@namespaces ||= {}
end

.namespaces=(namespaces) ⇒ Object

Sets the global namespaces. Expected to be a Hash containing the namespaces (keys) and the corresponding URI’s (values).



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

def self.namespaces=(namespaces)
  @@namespaces = namespaces if namespaces.kind_of? Hash
end

.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

#namespace=(namespace) ⇒ Object

Convenience method for setting the “xmlns:wsdl” namespace.



104
105
106
# File 'lib/savon/soap.rb', line 104

def namespace=(namespace)
  namespaces["xmlns:wsdl"] = namespace
end

#to_xmlObject

Returns the SOAP envelope XML.



119
120
121
122
123
124
125
126
127
# File 'lib/savon/soap.rb', line 119

def to_xml
  unless @xml_body
    @xml_body = @builder.env :Envelope, all_namespaces do |xml|
      xml_header xml
      xml_body xml
    end
  end
  @xml_body
end

#versionObject

Returns the SOAP version. Defaults to the global default.



114
115
116
# File 'lib/savon/soap.rb', line 114

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

#version=(version) ⇒ Object

Sets the SOAP version.



109
110
111
# File 'lib/savon/soap.rb', line 109

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