From cfbe2ed0750dc6e855e90ed0178cfd2ec585c2c9 Mon Sep 17 00:00:00 2001 From: Gregory Warnes Date: Tue, 23 Dec 2003 07:42:10 +0000 Subject: [PATCH] - Added 'strict' option to the WSDL class. If strict is true, a RuntimeException will be raised if an unrecogned message is recieved. If strict is false, a warning will be printed to the console, the message type will be added to the WSDL schema, and processing will continue. This is in response to the second half of bug report [ 817331 ] "Some WSDL.py changes", submitted by Rudolf Ruland. --- WSDLTools.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/WSDLTools.py b/WSDLTools.py index d2e71b7..edf8402 100755 --- a/WSDLTools.py +++ b/WSDLTools.py @@ -58,7 +58,7 @@ class WSDL: may be created manually or loaded from an xml representation using a WSDLReader instance.""" - def __init__(self, targetNamespace=None): + def __init__(self, targetNamespace=None, strict=1): self.targetNamespace = targetNamespace or 'urn:this-document.wsdl' self.documentation = '' self.location = None @@ -71,6 +71,7 @@ class WSDL: self.imports = Collection(self) self.types = Types(self) self.extensions = [] + self.strict = strict def __del__(self): if self.document is not None: @@ -1125,7 +1126,20 @@ def callInfoFromWSDL(port, name): ) if operation.output is not None: - message = messages[operation.output.message] + try: + message = messages[operation.output.message] + except KeyError: + if self.strict: + raise RuntimeError( + "Recieved message not defined in the WSDL schema: %s", + operation.output.message) + else: + message = wsdl.addMessage(operation.output.message) + print "Warning:", + "Recieved message not defined in the WSDL schema.", + "Adding it." + print "Message:", operation.output.message + msgrole = opbinding.output mime = msgrole.findBinding(MimeMultipartRelatedBinding)