MCPcopy Create free account
hub / github.com/ronreiter/interactive-tutorials / Document

Class Document

suds/bindings/document.py:28–160  ·  view source on GitHub ↗

The document/literal style. Literal is the only (@use) supported since document/encoded is pretty much dead. Although the soap specification supports multiple documents within the soap , it is very uncommon. As such, suds presents an I{RPC} view of service methods defin

Source from the content-addressed store, hash-verified

26
27
28class Document(Binding):
29 """
30 The document/literal style. Literal is the only (@use) supported
31 since document/encoded is pretty much dead.
32 Although the soap specification supports multiple documents within the soap
33 <body/>, it is very uncommon. As such, suds presents an I{RPC} view of
34 service methods defined with a single document parameter. This is done so
35 that the user can pass individual parameters instead of one, single
36 document.
37 To support the complete specification, service methods defined withs
38 multiple documents (multiple message parts), must present a I{document}
39 view for that method.
40 """
41
42 def bodycontent(self, method, args, kwargs):
43 #
44 # The I{wrapped} vs I{bare} style is detected in 2 ways.
45 # If there is 2+ parts in the message then it is I{bare}.
46 # If there is only (1) part and that part resolves to a builtin then
47 # it is I{bare}. Otherwise, it is I{wrapped}.
48 #
49 if not len(method.soap.input.body.parts):
50 return ()
51 wrapped = method.soap.input.body.wrapped
52 if wrapped:
53 pts = self.bodypart_types(method)
54 root = self.document(pts[0])
55 else:
56 root = []
57 n = 0
58 for pd in self.param_defs(method):
59 if n < len(args):
60 value = args[n]
61 else:
62 value = kwargs.get(pd[0])
63 n += 1
64 p = self.mkparam(method, pd, value)
65 if p is None:
66 continue
67 if not wrapped:
68 ns = pd[1].namespace('ns0')
69 p.setPrefix(ns[0], ns[1])
70 root.append(p)
71 return root
72
73 def replycontent(self, method, body):
74 wrapped = method.soap.output.body.wrapped
75 if wrapped:
76 return body[0].children
77 else:
78 return body.children
79
80 def document(self, wrapper):
81 """
82 Get the document root. For I{document/literal}, this is the
83 name of the wrapper element qualifed by the schema tns.
84 @param wrapper: The method name.
85 @type wrapper: L{xsd.sxbase.SchemaObject}

Callers 1

get_messageMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected