Class: Savon::SOAP::XML
- Inherits:
-
Object
- Object
- Savon::SOAP::XML
- Defined in:
- lib/savon/soap/xml.rb
Overview
Savon::SOAP::XML
Represents the SOAP request XML. Contains various global and per request/instance settings like the SOAP version, header, body and namespaces.
Constant Summary collapse
- SchemaTypes =
XML Schema Type namespaces.
{ "xmlns:xsd" => "http://www.w3.org/2001/XMLSchema", "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance" }
Instance Attribute Summary collapse
-
#body ⇒ Object
Accessor for the SOAP
body. -
#element_form_default ⇒ Object
Returns whether all local elements should be namespaced.
-
#endpoint ⇒ Object
Accessor for the SOAP
endpoint. -
#env_namespace ⇒ Object
Returns the SOAP envelope namespace.
-
#header ⇒ Object
Returns the SOAP
header. -
#input ⇒ Object
Accessor for the SOAP
inputtag. -
#namespace ⇒ Object
Accessor for the default namespace URI.
-
#namespace_identifier ⇒ Object
Returns the default namespace identifier.
-
#namespaces ⇒ Object
Returns the
namespaces. -
#wsse ⇒ Object
Accessor for the
Savon::WSSEobject. -
#xml ⇒ Object
Accepts a
blockand yields aBuilder::XmlMarkupobject to let you create custom XML.
Instance Method Summary collapse
-
#initialize(endpoint = nil, input = nil, body = nil) ⇒ XML
constructor
Accepts an
endpoint, aninputtag and a SOAPbody. -
#to_xml ⇒ Object
Returns the XML for a SOAP request.
-
#version ⇒ Object
Returns the SOAP
version. -
#version=(version) ⇒ Object
Sets the SOAP
version.
Constructor Details
#initialize(endpoint = nil, input = nil, body = nil) ⇒ XML
Accepts an endpoint, an input tag and a SOAP body.
28 29 30 31 32 |
# File 'lib/savon/soap/xml.rb', line 28 def initialize(endpoint = nil, input = nil, body = nil) self.endpoint = endpoint if endpoint self.input = input if input self.body = body if body end |
Instance Attribute Details
#body ⇒ Object
Accessor for the SOAP body. Expected to be a Hash that can be translated to XML via Gyoku.xml or any other Object responding to to_s.
103 104 105 |
# File 'lib/savon/soap/xml.rb', line 103 def body @body end |
#element_form_default ⇒ Object
Returns whether all local elements should be namespaced. Might be set to :qualified, but defaults to :unqualified.
88 89 90 |
# File 'lib/savon/soap/xml.rb', line 88 def element_form_default @element_form_default ||= :unqualified end |
#endpoint ⇒ Object
Accessor for the SOAP endpoint.
38 39 40 |
# File 'lib/savon/soap/xml.rb', line 38 def endpoint @endpoint end |
#env_namespace ⇒ Object
Returns the SOAP envelope namespace. Uses the global namespace if set Defaults to :env.
63 64 65 |
# File 'lib/savon/soap/xml.rb', line 63 def env_namespace @env_namespace ||= Savon.env_namespace.nil? ? :env : Savon.env_namespace end |
#header ⇒ Object
Returns the SOAP header. Defaults to an empty Hash.
55 56 57 |
# File 'lib/savon/soap/xml.rb', line 55 def header @header ||= Savon.soap_header.nil? ? {} : Savon.soap_header end |
#input ⇒ Object
Accessor for the SOAP input tag.
35 36 37 |
# File 'lib/savon/soap/xml.rb', line 35 def input @input end |
#namespace ⇒ Object
Accessor for the default namespace URI.
96 97 98 |
# File 'lib/savon/soap/xml.rb', line 96 def namespace @namespace end |
#namespace_identifier ⇒ Object
Returns the default namespace identifier.
82 83 84 |
# File 'lib/savon/soap/xml.rb', line 82 def namespace_identifier @namespace_identifier ||= :wsdl end |
#namespaces ⇒ Object
Returns the namespaces. Defaults to a Hash containing the SOAP envelope namespace.
71 72 73 74 75 76 |
# File 'lib/savon/soap/xml.rb', line 71 def namespaces @namespaces ||= begin key = env_namespace.blank? ? "xmlns" : "xmlns:#{env_namespace}" { key => SOAP::Namespace[version] } end end |
#wsse ⇒ Object
Accessor for the Savon::WSSE object.
99 100 101 |
# File 'lib/savon/soap/xml.rb', line 99 def wsse @wsse end |
#xml ⇒ Object
Accepts a block and yields a Builder::XmlMarkup object to let you create custom XML.
106 107 108 |
# File 'lib/savon/soap/xml.rb', line 106 def xml @xml = yield builder if block_given? end |
Instance Method Details
#to_xml ⇒ Object
Returns the XML for a SOAP request.
114 115 116 117 118 119 |
# File 'lib/savon/soap/xml.rb', line 114 def to_xml @xml ||= tag(builder, :Envelope, complete_namespaces) do |xml| tag(xml, :Header) { xml << header_for_xml } unless header_for_xml.empty? input.nil? ? tag(xml, :Body) : tag(xml, :Body) { xml.tag!(*input) { xml << body_to_xml } } end end |
#version ⇒ Object
Returns the SOAP version. Defaults to Savon.soap_version.
47 48 49 |
# File 'lib/savon/soap/xml.rb', line 47 def version @version ||= Savon.soap_version end |