Class: Savon::SOAP
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
-
.version ⇒ Object
Returns the default SOAP version.
Instance Attribute Summary collapse
-
#action ⇒ Object
Accessor for the SOAP action.
-
#body ⇒ Object
writeonly
Sets the SOAP body.
-
#header ⇒ Object
Returns the SOAP header.
-
#namespaces ⇒ Object
Returns the namespaces.
-
#wsse ⇒ Object
writeonly
Sets the WSSE options.
Instance Method Summary collapse
-
#initialize(action_map) ⇒ SOAP
constructor
Expects an
action_map
containing the name of the SOAP action and input. -
#to_xml ⇒ Object
Returns the SOAP envelope XML.
-
#version ⇒ Object
Returns the SOAP version.
-
#version=(version) ⇒ Object
Sets the SOAP version.
Constructor Details
#initialize(action_map) ⇒ SOAP
Expects an action_map
containing the name of the SOAP action and input.
33 34 35 36 |
# File 'lib/savon/soap.rb', line 33 def initialize(action_map) @action = action_map[:name] @input = action_map[:input] end |
Class Attribute Details
.version ⇒ Object
Returns the default SOAP version.
23 24 25 |
# File 'lib/savon/soap.rb', line 23 def version @version end |
Instance Attribute Details
#action ⇒ Object
Accessor for the SOAP action.
42 43 44 |
# File 'lib/savon/soap.rb', line 42 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.
55 56 57 |
# File 'lib/savon/soap.rb', line 55 def body=(value) @body = value end |
#header ⇒ Object
Returns the SOAP header. Defaults to an empty Hash.
49 50 51 |
# File 'lib/savon/soap.rb', line 49 def header @header ||= {} end |
#namespaces ⇒ Object
Returns the namespaces. A Hash containing the namespaces (keys) and the corresponding URI’s (values).
63 64 65 |
# File 'lib/savon/soap.rb', line 63 def namespaces @namespaces ||= { "xmlns:env" => SOAPNamespace[version] } end |
#wsse=(value) ⇒ Object (writeonly)
Sets the WSSE options.
39 40 41 |
# File 'lib/savon/soap.rb', line 39 def wsse=(value) @wsse = value end |
Instance Method Details
#to_xml ⇒ Object
Returns the SOAP envelope XML.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/savon/soap.rb', line 78 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.wsdl(@input.to_sym) do xml << (@body.to_soap_xml rescue @body.to_s) end end end end @xml_body end |
#version ⇒ Object
Returns the SOAP version. Defaults to the global default.
73 74 75 |
# File 'lib/savon/soap.rb', line 73 def version @version ||= self.class.version end |
#version=(version) ⇒ Object
Sets the SOAP version.
68 69 70 |
# File 'lib/savon/soap.rb', line 68 def version=(version) @version = version if Savon::SOAPVersions.include? version end |