RPC/Literal binding style.
| 31 | |
| 32 | |
| 33 | class RPC(Binding): |
| 34 | """ |
| 35 | RPC/Literal binding style. |
| 36 | """ |
| 37 | |
| 38 | def param_defs(self, method): |
| 39 | return self.bodypart_types(method) |
| 40 | |
| 41 | def envelope(self, header, body): |
| 42 | env = Binding.envelope(self, header, body) |
| 43 | env.addPrefix(encns[0], encns[1]) |
| 44 | env.set('%s:encodingStyle' % envns[0], |
| 45 | 'http://schemas.xmlsoap.org/soap/encoding/') |
| 46 | return env |
| 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 | |
| 65 | def method(self, method): |
| 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 | |
| 81 | class Encoded(RPC): |