Class: SOAP::SOAPBody

Inherits:
SOAPStruct show all
Includes:
SOAPEnvelopeElement
Defined in:
lib/action_web_service/soap/rpc/element.rb,
lib/action_web_service/soap/element.rb

Overview

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

Constant Summary

Constants included from SOAP

AttrActor, AttrArrayType, AttrArrayTypeName, AttrEncodingStyle, AttrEncodingStyleName, AttrMustUnderstand, AttrMustUnderstandName, AttrOffset, AttrOffsetName, AttrPosition, AttrPositionName, AttrRoot, AttrRootName, Base64Literal, EleBody, EleBodyName, EleEnvelope, EleEnvelopeName, EleFault, EleFaultActor, EleFaultActorName, EleFaultCode, EleFaultCodeName, EleFaultDetail, EleFaultDetailName, EleFaultName, EleFaultString, EleFaultStringName, EleHeader, EleHeaderName, EncodingNamespace, EnvelopeNamespace, LiteralNamespace, MediaType, NextActor, PropertyName, SOAPNamespaceTag, TypeMap, VERSION, ValueArray, ValueArrayName, XSDNamespaceTag, XSINamespaceTag

Instance Attribute Summary

Attributes included from SOAPType

#definedtype, #elename, #encodingstyle, #extraattr, #id, #parent, #position, #precedents, #root

Attributes inherited from XSD::NSDBase

#type

Instance Method Summary collapse

Methods inherited from SOAPStruct

#[], #[]=, #add, decode, #each, #key?, #members, #replace, #to_obj, #to_s

Methods included from SOAPType

#inspect, #rootnode

Methods inherited from XSD::NSDBase

inherited, #init, types

Constructor Details

#initialize(data = nil, is_fault = false) ⇒ SOAPBody

Returns a new instance of SOAPBody.



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/action_web_service/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

Instance Method Details

#encode(generator, ns, attrs = {}) ⇒ Object



114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/action_web_service/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

#faultObject



49
50
51
52
53
54
55
# File 'lib/action_web_service/soap/rpc/element.rb', line 49

def fault
  if @is_fault
    self['fault']
  else
    nil
  end
end

#fault=(fault) ⇒ Object



57
58
59
60
# File 'lib/action_web_service/soap/rpc/element.rb', line 57

def fault=(fault)
  @is_fault = true
  add_member('fault', fault)
end

#outparamsObject



38
39
40
41
42
43
44
45
46
47
# File 'lib/action_web_service/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

#requestObject



18
19
20
# File 'lib/action_web_service/soap/rpc/element.rb', line 18

def request
  root_node
end

#responseObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/action_web_service/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

#root_nodeObject



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/action_web_service/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