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 Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Builder.



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/savon/builder.rb', line 24

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

  @wsdl      = wsdl
  @globals   = globals
  @locals    = locals
  @signature = @locals[:wsse_signature] || @globals[:wsse_signature]

  @types = convert_type_definitions_to_hash
  @used_namespaces = convert_type_namespaces_to_hash
end

Instance Attribute Details

#multipartObject (readonly)

Returns the value of attribute multipart.



10
11
12
# File 'lib/savon/builder.rb', line 10

def multipart
  @multipart
end

Instance Method Details

#body_attributesObject



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

def body_attributes
  @body_attributes ||= @signature.nil? ? {} : @signature.body_attributes
end

#build_documentObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/savon/builder.rb', line 40

def build_document
  # check if xml was already provided
  if @locals.include? :xml
    xml_result = @locals[:xml]
  else
    xml_result = build_xml

    # if we have a signature sign the document
    if @signature
      @signature.document = xml_result

      2.times do
        @header             = nil
        @signature.document = build_xml
      end

      xml_result = @signature.document
    end
  end

  # if there are attachments for the request, we should build a multipart message according to
  # https://www.w3.org/TR/SOAP-attachments
  if @locals[:attachments]
    build_multipart_message(xml_result)
  else
    xml_result
  end
end

#header_attributesObject



69
70
71
# File 'lib/savon/builder.rb', line 69

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

#prettyObject



36
37
38
# File 'lib/savon/builder.rb', line 36

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

#to_sObject



77
78
79
# File 'lib/savon/builder.rb', line 77

def to_s
  build_document
end