1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 """
18 Provides classes for the (WS) SOAP I{rpc/literal} and I{rpc/encoded} bindings.
19 """
20
21 from logging import getLogger
22 from suds import *
23 from suds.mx.encoded import Encoded as MxEncoded
24 from suds.umx.encoded import Encoded as UmxEncoded
25 from suds.bindings.binding import Binding, envns
26 from suds.sax.element import Element
27
28 log = getLogger(__name__)
29
30
31 encns = ('SOAP-ENC', 'http://schemas.xmlsoap.org/soap/encoding/')
32
34 """
35 RPC/Literal binding style.
36 """
37
40
47
48 - def bodycontent(self, method, args, kwargs):
49 n = 0
50 root = self.method(method)
51 for pd in self.param_defs(method):
52 if n < len(args):
53 value = args[n]
54 else:
55 value = kwargs.get(pd[0])
56 p = self.mkparam(method, pd, value)
57 if p is not None:
58 root.append(p)
59 n += 1
60 return root
61
62 - def replycontent(self, method, body):
63 return body[0].children
64
66 """
67 Get the document root. For I{rpc/(literal|encoded)}, this is the
68 name of the method qualifed by the schema tns.
69 @param method: A service method.
70 @type method: I{service.Method}
71 @return: A root element.
72 @rtype: L{Element}
73 """
74 ns = method.soap.input.body.namespace
75 if ns[0] is None:
76 ns = ('ns0', ns[1])
77 method = Element(method.name, ns=ns)
78 return method
79
80
82 """
83 RPC/Encoded (section 5) binding style.
84 """
85
87 return MxEncoded(self.schema())
88
90 """
91 Get the appropriate XML decoder.
92 @return: Either the (basic|typed) unmarshaller.
93 @rtype: L{UmxTyped}
94 """
95 if typed:
96 return UmxEncoded(self.schema())
97 else:
98 return RPC.unmarshaller(self, typed)
99