1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 """
18 Provides soap encoded unmarshaller classes.
19 """
20
21 from logging import getLogger
22 from suds import *
23 from suds.umx import *
24 from suds.umx.typed import Typed
25 from suds.sax import splitPrefix, Namespace
26
27 log = getLogger(__name__)
28
29
30
31
32
33 Content.extensions.append('aty')
34
35
37 """
38 A SOAP section (5) encoding unmarshaller.
39 This marshaller supports rpc/encoded soap styles.
40 """
41
42 - def start(self, content):
48
49 - def end(self, content):
59
60 - def postprocess(self, content):
61
62
63
64 if content.aty is None:
65 return Typed.postprocess(self, content)
66 else:
67 return content.data
68
70 """
71 Grab the (aty) soap-enc:arrayType and attach it to the
72 content for proper array processing later in end().
73 @param content: The current content being unmarshalled.
74 @type content: L{Content}
75 @return: self
76 @rtype: L{Encoded}
77 """
78 name = 'arrayType'
79 ns = (None, 'http://schemas.xmlsoap.org/soap/encoding/')
80 aty = content.node.get(name, ns)
81 if aty is not None:
82 content.aty = aty
83 parts = aty.split('[')
84 ref = parts[0]
85 if len(parts) == 2:
86 self.applyaty(content, ref)
87 else:
88 pass
89 return self
90
92 """
93 Apply the type referenced in the I{arrayType} to the content
94 (child nodes) of the array. Each element (node) in the array
95 that does not have an explicit xsi:type attribute is given one
96 based on the I{arrayType}.
97 @param content: An array content.
98 @type content: L{Content}
99 @param xty: The XSI type reference.
100 @type xty: str
101 @return: self
102 @rtype: L{Encoded}
103 """
104 name = 'type'
105 ns = Namespace.xsins
106 parent = content.node
107 for child in parent.getChildren():
108 ref = child.get(name, ns)
109 if ref is None:
110 parent.addPrefix(ns[0], ns[1])
111 attr = ':'.join((ns[0], name))
112 child.set(attr, xty)
113 return self
114
129