| Class | SOAP::SOAPBody |
| In: |
lib/soap/element.rb
lib/soap/rpc/element.rb |
| Parent: | SOAPStruct |
Add method definitions for RPC to common definition in element.rb
# File lib/soap/element.rb, line 98
98: def initialize(data = nil, is_fault = false)
99: super(nil)
100: @elename = EleBodyName
101: @encodingstyle = nil
102: if data
103: if data.respond_to?(:elename)
104: add(data.elename.name, data)
105: else
106: data.to_a.each do |datum|
107: add(datum.elename.name, datum)
108: end
109: end
110: end
111: @is_fault = is_fault
112: end
# File lib/soap/element.rb, line 114
114: def encode(generator, ns, attrs = {})
115: name = ns.name(@elename)
116: generator.encode_tag(name, attrs)
117: if @is_fault
118: yield(@data)
119: else
120: @data.each do |data|
121: yield(data)
122: end
123: end
124: generator.encode_tag_end(name, true)
125: end
# File lib/soap/rpc/element.rb, line 49
49: def fault
50: if @is_fault
51: self['fault']
52: else
53: nil
54: end
55: end
# File lib/soap/rpc/element.rb, line 57
57: def fault=(fault)
58: @is_fault = true
59: add_member('fault', fault)
60: end
# File lib/soap/rpc/element.rb, line 38
38: def outparams
39: root = root_node
40: if !@is_fault and !root.nil? and !root.is_a?(SOAPBasetype)
41: op = root[1..-1]
42: op = nil if op && op.empty?
43: op
44: else
45: nil
46: end
47: end
# File lib/soap/rpc/element.rb, line 22
22: def response
23: root = root_node
24: if !@is_fault
25: if root.nil?
26: nil
27: elsif root.is_a?(SOAPBasetype)
28: root
29: else
30: # Initial element is [retval].
31: root[0]
32: end
33: else
34: root
35: end
36: end
# File lib/soap/element.rb, line 127
127: def root_node
128: @data.each do |node|
129: if node.root == 1
130: return node
131: end
132: end
133: # No specified root...
134: @data.each do |node|
135: if node.root != 0
136: return node
137: end
138: end
139:
140: raise Parser::FormatDecodeError.new('no root element')
141: end