Class: Savon::Builder
- Inherits:
-
Object
- Object
- Savon::Builder
- 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
- #body_attributes ⇒ Object
- #build_document ⇒ Object
- #header_attributes ⇒ Object
-
#initialize(operation_name, wsdl, globals, locals) ⇒ Builder
constructor
A new instance of Builder.
- #pretty ⇒ Object
- #to_s ⇒ Object
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 32 |
# File 'lib/savon/builder.rb', line 22 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 Method Details
#body_attributes ⇒ Object
74 75 76 |
# File 'lib/savon/builder.rb', line 74 def body_attributes @body_attributes ||= @signature.nil? ? {} : @signature.body_attributes end |
#build_document ⇒ Object
38 39 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 68 |
# File 'lib/savon/builder.rb', line 38 def build_document xml_result = tag(builder, :Envelope, namespaces_with_globals) do |xml| tag(xml, :Header, header_attributes) { xml << header.to_s } unless header.empty? if @globals[:no_message_tag] tag(xml, :Body, body_attributes) { xml << .to_s } else tag(xml, :Body, body_attributes) { xml.tag!(*) { xml << } } end end # if we have a signature sign the document if @signature @signature.document = xml_result 2.times do @header = nil @signature.document = tag(builder, :Envelope, namespaces_with_globals) do |xml| tag(xml, :Header, header_attributes) { xml << header.to_s } unless header.empty? if @globals[:no_message_tag] tag(xml, :Body, body_attributes) { xml << .to_s } else tag(xml, :Body, body_attributes) { xml.tag!(*) { xml << .to_s } } end end end xml_result = @signature.document end xml_result end |
#header_attributes ⇒ Object
70 71 72 |
# File 'lib/savon/builder.rb', line 70 def header_attributes @globals[:use_wsa_headers] ? { 'xmlns:wsa' => WSA_NAMESPACE } : {} end |
#pretty ⇒ Object
34 35 36 |
# File 'lib/savon/builder.rb', line 34 def pretty Nokogiri.XML(to_s).to_xml(:indent => 2) end |
#to_s ⇒ Object
78 79 80 81 |
# File 'lib/savon/builder.rb', line 78 def to_s return @locals[:xml] if @locals.include? :xml build_document end |