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

Class ServiceDefinition

suds/servicedefinition.py:29–272  ·  view source on GitHub ↗

A service definition provides an object used to generate a textual description of a service. @ivar wsdl: A wsdl. @type wsdl: L{wsdl.Definitions} @ivar service: The service object. @type service: L{suds.wsdl.Service} @ivar ports: A list of port-tuple: (port, [(method-name

Source from the content-addressed store, hash-verified

27
28
29class ServiceDefinition:
30 """
31 A service definition provides an object used to generate a textual
32 description of a service.
33 @ivar wsdl: A wsdl.
34 @type wsdl: L{wsdl.Definitions}
35 @ivar service: The service object.
36 @type service: L{suds.wsdl.Service}
37 @ivar ports: A list of port-tuple: (port, [(method-name, pdef)])
38 @type ports: [port-tuple,..]
39 @ivar prefixes: A list of remapped prefixes.
40 @type prefixes: [(prefix,uri),..]
41 @ivar types: A list of type definitions
42 @type types: [I{Type},..]
43 """
44
45 def __init__(self, wsdl, service):
46 """
47 @param wsdl: A wsdl object
48 @type wsdl: L{Definitions}
49 @param service: A service B{name}.
50 @type service: str
51 """
52 self.wsdl = wsdl
53 self.service = service
54 self.ports = []
55 self.params = []
56 self.types = []
57 self.prefixes = []
58 self.addports()
59 self.paramtypes()
60 self.publictypes()
61 self.getprefixes()
62 self.pushprefixes()
63
64 def pushprefixes(self):
65 """
66 Add our prefixes to the wsdl so that when users invoke methods
67 and reference the prefixes, the will resolve properly.
68 """
69 for ns in self.prefixes:
70 self.wsdl.root.addPrefix(ns[0], ns[1])
71
72 def addports(self):
73 """
74 Look through the list of service ports and construct a list of tuples
75 where each tuple is used to describe a port and it's list of methods
76 as: (port, [method]). Each method is tuple: (name, [pdef,..] where
77 each pdef is a tuple: (param-name, type).
78 """
79 timer = metrics.Timer()
80 timer.start()
81 for port in self.service.ports:
82 p = self.findport(port)
83 for op in port.binding.operations.values():
84 m = p[0].method(op.name)
85 binding = m.binding.input
86 method = (m.name, binding.param_defs(m))

Callers 1

__init__Method · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected