Class: Savon::SOAP
Overview
Savon::SOAP
Represents the SOAP parameters and envelope.
Constant Summary collapse
- Namespace =
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" }
- Versions =
Supported SOAP versions.
[1, 2]
- DateTimeFormat =
SOAP xs:dateTime format.
"%Y-%m-%dT%H:%M:%SZ"
- DateTimeRegexp =
SOAP xs:dateTime Regexp.
/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/
- @@version =
The global SOAP version.
1
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the SOAP action.
-
#body ⇒ Object
writeonly
Sets the SOAP body.
-
#endpoint ⇒ Object
Accessor for the SOAP endpoint.
-
#header ⇒ Object
Returns the SOAP header.
-
#input ⇒ Object
Returns the SOAP input.
-
#namespaces ⇒ Object
Returns the namespaces.
-
#wsse ⇒ Object
writeonly
Sets the WSSE options.
Class Method Summary collapse
-
.header ⇒ Object
Returns the global SOAP header.
-
.header=(header) ⇒ Object
Sets the global SOAP header.
-
.namespaces ⇒ Object
Returns the global namespaces.
-
.namespaces=(namespaces) ⇒ Object
Sets the global namespaces.
-
.version ⇒ Object
Returns the global SOAP version.
-
.version=(version) ⇒ Object
Sets the global SOAP version.
Instance Method Summary collapse
-
#initialize(operation, endpoint) ⇒ SOAP
constructor
Initialzes the SOAP object.
-
#namespace=(namespace) ⇒ Object
Convenience method for setting the “xmlns:wsdl” namespace.
-
#to_xml ⇒ Object
Returns the SOAP envelope XML.
-
#version ⇒ Object
Returns the SOAP version.
-
#version=(version) ⇒ Object
Sets the SOAP version.
Constructor Details
#initialize(operation, endpoint) ⇒ SOAP
Initialzes the SOAP object.
63 64 65 66 67 |
# File 'lib/savon/soap.rb', line 63 def initialize(operation, endpoint) @action, @input = operation[:action], operation[:input] @endpoint = endpoint.kind_of?(URI) ? endpoint : URI(endpoint) @builder = Builder::XmlMarkup.new end |
Instance Attribute Details
#action ⇒ Object
Returns the SOAP action.
76 77 78 |
# File 'lib/savon/soap.rb', line 76 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.
102 103 104 |
# File 'lib/savon/soap.rb', line 102 def body=(value) @body = value end |
#endpoint ⇒ Object
Accessor for the SOAP endpoint.
89 90 91 |
# File 'lib/savon/soap.rb', line 89 def endpoint @endpoint end |
#header ⇒ Object
Returns the SOAP header. Defaults to an empty Hash.
96 97 98 |
# File 'lib/savon/soap.rb', line 96 def header @header ||= {} end |
#input ⇒ Object
Returns the SOAP input.
84 85 86 |
# File 'lib/savon/soap.rb', line 84 def input @input ||= "" end |
#namespaces ⇒ Object
Returns the namespaces. A Hash containing the namespaces (keys) and the corresponding URI’s (values).
110 111 112 |
# File 'lib/savon/soap.rb', line 110 def namespaces @namespaces ||= { "xmlns:env" => Namespace[version] } end |
#wsse=(value) ⇒ Object (writeonly)
Sets the WSSE options.
70 71 72 |
# File 'lib/savon/soap.rb', line 70 def wsse=(value) @wsse = value end |
Class Method Details
.header ⇒ Object
Returns the global SOAP header. Defaults to an empty Hash.
46 47 48 |
# File 'lib/savon/soap.rb', line 46 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.
41 42 43 |
# File 'lib/savon/soap.rb', line 41 def self.header=(header) @@header = header end |
.namespaces ⇒ Object
Returns the global namespaces. A Hash containing the namespaces (keys) and the corresponding URI’s (values).
58 59 60 |
# File 'lib/savon/soap.rb', line 58 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).
52 53 54 |
# File 'lib/savon/soap.rb', line 52 def self.namespaces=(namespaces) @@namespaces = namespaces if namespaces.kind_of? Hash end |
.version ⇒ Object
Returns the global SOAP version.
30 31 32 |
# File 'lib/savon/soap.rb', line 30 def self.version @@version end |
Instance Method Details
#namespace=(namespace) ⇒ Object
Convenience method for setting the “xmlns:wsdl” namespace.
115 116 117 |
# File 'lib/savon/soap.rb', line 115 def namespace=(namespace) namespaces["xmlns:wsdl"] = namespace end |
#to_xml ⇒ Object
Returns the SOAP envelope XML.
130 131 132 133 134 135 136 137 138 |
# File 'lib/savon/soap.rb', line 130 def to_xml unless @xml_body @xml_body = @builder.env :Envelope, all_namespaces do |xml| xml.env(:Header) { xml << all_header } unless all_header.empty? xml_body xml end end @xml_body end |
#version ⇒ Object
Returns the SOAP version. Defaults to the global default.
125 126 127 |
# File 'lib/savon/soap.rb', line 125 def version @version ||= self.class.version end |