# File soap/encodingstyle/soapHandler.rb, line 211
def decode_epilogue
decode_resolve_id
end
# File soap/encodingstyle/soapHandler.rb, line 215
def decode_parent(parent, node)
return unless parent.node
case parent.node
when SOAPUnknown
newparent = parent.node.as_struct
node.parent = newparent
if newparent.id
@idpool << newparent
end
parent.replace_node(newparent)
decode_parent(parent, node)
when SOAPStruct
parent.node.add(node.elename.name, node)
node.parent = parent.node
when SOAPArray
if node.position
parent.node[*(decode_arypos(node.position))] = node
parent.node.sparse = true
else
parent.node.add(node)
end
node.parent = parent.node
else
raise EncodingStyleError.new("illegal parent: #{parent.node}")
end
end
# File soap/encodingstyle/soapHandler.rb, line 205
def decode_prologue
@refpool.clear
@idpool.clear
@is_first_top_ele = true
end
# File soap/encodingstyle/soapHandler.rb, line 145
def decode_tag(ns, elename, attrs, parent)
@textbuf = ''
is_nil, type, arytype, root, offset, position, href, id, extraattr =
decode_attrs(ns, attrs)
o = nil
if is_nil
o = SOAPNil.decode(elename)
elsif href
o = SOAPReference.decode(elename, href)
@refpool << o
elsif @decode_typemap
o = decode_tag_by_wsdl(ns, elename, type, parent.node, arytype, extraattr)
else
o = decode_tag_by_type(ns, elename, type, parent.node, arytype, extraattr)
end
if o.is_a?(SOAPArray)
if offset
o.offset = decode_arypos(offset)
o.sparse = true
else
o.sparse = false
end
end
o.parent = parent
o.id = id
o.root = root
o.position = position
unless o.is_a?(SOAPTemporalObject)
@idpool << o if o.id
decode_parent(parent, o)
end
o
end
# File soap/encodingstyle/soapHandler.rb, line 182
def decode_tag_end(ns, node)
o = node.node
if o.is_a?(SOAPUnknown)
newnode = if /\A\s*\z/ =~ @textbuf
o.as_struct
else
o.as_string
end
if newnode.id
@idpool << newnode
end
node.replace_node(newnode)
o = node.node
end
decode_textbuf(o)
# unlink definedtype
o.definedtype = nil
end
# File soap/encodingstyle/soapHandler.rb, line 201
def decode_text(ns, text)
@textbuf << text
end
encode interface.
# File soap/encodingstyle/soapHandler.rb, line 32
def encode_data(generator, ns, data, parent)
attrs = encode_attrs(generator, ns, data, parent)
if parent && parent.is_a?(SOAPArray) && parent.position
attrs[ns.name(AttrPositionName)] = "[#{parent.position.join(',')}]"
end
name = generator.encode_name(ns, data, attrs)
case data
when SOAPReference
attrs['href'] = data.refidstr
generator.encode_tag(name, attrs)
when SOAPExternalReference
data.referred
attrs['href'] = data.refidstr
generator.encode_tag(name, attrs)
when SOAPRawString
generator.encode_tag(name, attrs)
generator.encode_rawstring(data.to_s)
when XSD::XSDString
generator.encode_tag(name, attrs)
generator.encode_string(@charset ?
XSD::Charset.encoding_to_xml(data.to_s, @charset) : data.to_s)
when XSD::XSDAnySimpleType
generator.encode_tag(name, attrs)
generator.encode_string(data.to_s)
when SOAPStruct
generator.encode_tag(name, attrs)
data.each do |key, value|
generator.encode_child(ns, value, data)
end
when SOAPArray
generator.encode_tag(name, attrs)
data.traverse do |child, *rank|
data.position = data.sparse ? rank : nil
generator.encode_child(ns, child, data)
end
else
raise EncodingStyleError.new(
"unknown object:#{data} in this encodingStyle")
end
end