Class SOAP::SOAPBody
In: soap/rpc/element.rb
soap/element.rb
Parent: SOAPStruct

Add method definitions for RPC to common definition in element.rb

Methods

encode   fault   fault=   new   outparams   request   response   root_node  

Included Modules

SOAPEnvelopeElement

Public Class methods

[Source]

# File soap/element.rb, line 98
  def initialize(data = nil, is_fault = false)
    super(nil)
    @elename = EleBodyName
    @encodingstyle = nil
    if data
      if data.respond_to?(:elename)
        add(data.elename.name, data)
      else
        data.to_a.each do |datum|
          add(datum.elename.name, datum)
        end
      end
    end
    @is_fault = is_fault
  end

Public Instance methods

[Source]

# File soap/element.rb, line 114
  def encode(generator, ns, attrs = {})
    name = ns.name(@elename)
    generator.encode_tag(name, attrs)
    if @is_fault
      yield(@data)
    else
      @data.each do |data|
        yield(data)
      end
    end
    generator.encode_tag_end(name, true)
  end

[Source]

# File soap/rpc/element.rb, line 49
  def fault
    if @is_fault
      self['fault']
    else
      nil
    end
  end

[Source]

# File soap/rpc/element.rb, line 57
  def fault=(fault)
    @is_fault = true
    add_member('fault', fault)
  end

[Source]

# File soap/rpc/element.rb, line 38
  def outparams
    root = root_node
    if !@is_fault and !root.nil? and !root.is_a?(SOAPBasetype)
      op = root[1..-1]
      op = nil if op && op.empty?
      op
    else
      nil
    end
  end

[Source]

# File soap/rpc/element.rb, line 18
  def request
    root_node
  end

[Source]

# File soap/rpc/element.rb, line 22
  def response
    root = root_node
    if !@is_fault
      if root.nil?
        nil
      elsif root.is_a?(SOAPBasetype)
        root
      else
        # Initial element is [retval].
        root[0]
      end
    else
      root
    end
  end

[Source]

# File soap/element.rb, line 127
  def root_node
    @data.each do |node|
      if node.root == 1
        return node
      end
    end
    # No specified root...
    @data.each do |node|
      if node.root != 0
        return node
      end
    end

    raise Parser::FormatDecodeError.new('no root element')
  end

[Validate]