Given the wsdl may not contain a <schema/> element, the get_schema() is changed to ensure that at least one (default) schema is contained in the returned collection

This commit is contained in:
jortel 2008-04-28 16:55:35 +00:00
parent 34f7663df1
commit 7c9e942064
3 changed files with 24 additions and 7 deletions

View File

@ -111,6 +111,19 @@ class Element:
'endswith' : lambda a,b: a.endswith(b),
'contains' : lambda a,b: b in a
}
@classmethod
def buildPath(self, parent, path):
"""
build the specifed path as a/b/c where missing intermediate nodes are built
automatically
"""
for tag in path.split('/'):
child = parent.getChild(tag)
if child is None:
child = Element(tag, parent)
parent = child
return child
def __init__(self, name, parent=None, ns=None):
self.prefix, self.name = splitPrefix(name)

View File

@ -101,10 +101,14 @@ class WSDL:
def get_schema(self):
""" get a collective schema of all <schema/> nodes """
container = SchemaCollection(self)
for sr in self.root.childrenAtPath('types/schema'):
schema = Schema(sr, self.url, container)
for root in self.root.childrenAtPath('types/schema'):
schema = Schema(root, self.url, container)
container.append(schema)
self.log.debug('schema (container):\n', container)
if not len(container): # empty
root = Element.buildPath(self.root, 'types/schema')
schema = Schema(root, self.url, container)
container.append(schema)
self.log.debug('schema (container):\n%s', container)
return container
def get_servicename(self):

View File

@ -47,10 +47,10 @@ class Test:
def test_misc(self):
service = ServiceProxy('https://sec.neurofuzz-software.com/paos/genSSHA-SOAP.php?wsdl',
faults=True,
nil_supported=False,
proxy={'http':'10.1.1.1'})
service = ServiceProxy('http://soa.ebrev.info/service.wsdl')
print service
service = ServiceProxy('https://sec.neurofuzz-software.com/paos/genSSHA-SOAP.php?wsdl')
print service
print service.genSSHA('hello', 'sha1')