Class: Savon::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/savon/builder.rb

Constant Summary collapse

SCHEMA_TYPES =
{
  "xmlns:xsd" => "http://www.w3.org/2001/XMLSchema",
  "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance"
}
SOAP_NAMESPACE =
{
  1 => "http://schemas.xmlsoap.org/soap/envelope/",
  2 => "http://www.w3.org/2003/05/soap-envelope"
}
WSA_NAMESPACE =
"http://www.w3.org/2005/08/addressing"

Instance Method Summary collapse

Constructor Details

#initialize(operation_name, wsdl, globals, locals) ⇒ Builder

Returns a new instance of Builder.



22
23
24
25
26
27
28
29
30
31
# File 'lib/savon/builder.rb', line 22

def initialize(operation_name, wsdl, globals, locals)
  @operation_name = operation_name

  @wsdl    = wsdl
  @globals = globals
  @locals  = locals

  @types = convert_type_definitions_to_hash
  @used_namespaces = convert_type_namespaces_to_hash
end

Instance Method Details

#body_attributesObject



48
49
# File 'lib/savon/builder.rb', line 48

def body_attributes
end

#build_documentObject



37
38
39
40
41
42
# File 'lib/savon/builder.rb', line 37

def build_document
  tag(builder, :Envelope, namespaces_with_globals) do |xml|
    tag(xml, :Header, header_attributes) { xml << header.to_s } unless header.empty?
    tag(xml, :Body, body_attributes) { xml.tag!(*namespaced_message_tag) { xml << message.to_s } }
  end
end

#header_attributesObject



44
45
46
# File 'lib/savon/builder.rb', line 44

def header_attributes
   { 'xmlns:wsa' => WSA_NAMESPACE } if @globals[:use_wsa_headers]
end

#prettyObject



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

def pretty
  Nokogiri.XML(to_s).to_xml(:indent => 2)
end

#to_sObject



51
52
53
54
# File 'lib/savon/builder.rb', line 51

def to_s
  return @locals[:xml] if @locals.include? :xml
  build_document
end