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"
}.freeze
SOAP_NAMESPACE =
{
  1 => "http://schemas.xmlsoap.org/soap/envelope/",
  2 => "http://www.w3.org/2003/05/soap-envelope"
}.freeze
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.



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

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.



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

def multipart
  @multipart
end

Instance Method Details

#body_attributesObject



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

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

#build_documentObject



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

def build_document
  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

  # 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



65
66
67
# File 'lib/savon/builder.rb', line 65

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

#prettyObject



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

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

#to_sObject



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

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

  build_document
end