Modified Files:
Namespaces.py
-- Added a SOAP-1.2 binding
WSDLTools.py
-- Added some methods from grabbing ElementDeclaration and
TypeDefintion from Message instances.
XMLSchema.py
-- fixed a bug in SchemaReader.
logging.py
-- added a couple more functions, and a level to basic logger.
----------------------------------------------------------------------
main
| @@ -28,6 +28,7 @@ except: | |||||
| BIND_HTTP = "http://schemas.xmlsoap.org/wsdl/http/" | BIND_HTTP = "http://schemas.xmlsoap.org/wsdl/http/" | ||||
| BIND_MIME = "http://schemas.xmlsoap.org/wsdl/mime/" | BIND_MIME = "http://schemas.xmlsoap.org/wsdl/mime/" | ||||
| BIND_SOAP = "http://schemas.xmlsoap.org/wsdl/soap/" | BIND_SOAP = "http://schemas.xmlsoap.org/wsdl/soap/" | ||||
| BIND_SOAP12 = "http://schemas.xmlsoap.org/wsdl/soap12/" | |||||
| class XMLNS: | class XMLNS: | ||||
| BASE = "http://www.w3.org/2000/xmlns/" | BASE = "http://www.w3.org/2000/xmlns/" | ||||
| @@ -438,6 +438,26 @@ class Message(Element): | |||||
| if elemref is not None: | if elemref is not None: | ||||
| part.element = ParseTypeRef(elemref, element) | part.element = ParseTypeRef(elemref, element) | ||||
| def getElementDeclaration(self): | |||||
| """Return the XMLSchema.ElementDeclaration instance or None""" | |||||
| element = None | |||||
| if self.element: | |||||
| nsuri,name = self.element | |||||
| wsdl = self.getWSDL() | |||||
| if wsdl.types.has_key(nsuri) and wsdl.types[nsuri].elements.has_key(name): | |||||
| element = wsdl.types[nsuri].elements[name] | |||||
| return element | |||||
| def getTypeDefinition(self): | |||||
| """Return the XMLSchema.TypeDefinition instance or None""" | |||||
| type = None | |||||
| if self.type: | |||||
| nsuri,name = self.type | |||||
| wsdl = self.getWSDL() | |||||
| if wsdl.types.has_key(nsuri) and wsdl.types[nsuri].types.has_key(name): | |||||
| type = wsdl.types[nsuri].types[name] | |||||
| return type | |||||
| def getWSDL(self): | def getWSDL(self): | ||||
| """Return the WSDL object that contains this Message Part.""" | """Return the WSDL object that contains this Message Part.""" | ||||
| return self.parent().parent() | return self.parent().parent() | ||||
| @@ -681,6 +701,13 @@ class MessageRole(Element): | |||||
| return self.parent().parent().getWSDL() | return self.parent().parent().getWSDL() | ||||
| return self.parent().getWSDL() | return self.parent().getWSDL() | ||||
| def getMessage(self): | |||||
| """Return the WSDL object that represents the attribute message | |||||
| (namespaceURI, name) tuple | |||||
| """ | |||||
| wsdl = self.getWSDL() | |||||
| return wsdl.messages[self.message] | |||||
| def toDom(self, node): | def toDom(self, node): | ||||
| wsdl = self.getWSDL() | wsdl = self.getWSDL() | ||||
| @@ -1040,7 +1067,7 @@ class Port(Element): | |||||
| def getAddressBinding(self): | def getAddressBinding(self): | ||||
| """A convenience method to obtain the extension element used | """A convenience method to obtain the extension element used | ||||
| as the address binding for the port, or None if undefined.""" | |||||
| as the address binding for the port.""" | |||||
| for item in self.extensions: | for item in self.extensions: | ||||
| if isinstance(item, SoapAddressBinding) or \ | if isinstance(item, SoapAddressBinding) or \ | ||||
| isinstance(item, HttpAddressBinding): | isinstance(item, HttpAddressBinding): | ||||
| @@ -1577,13 +1604,6 @@ def callInfoFromWSDL(port, name): | |||||
| parts = message.parts.values() | parts = message.parts.values() | ||||
| if parts: | if parts: | ||||
| # XXX no idea what this is for, but it breaks everything. jrb | |||||
| #callinfo.setReturnParameter( | |||||
| # parts[0].name, | |||||
| # parts[0].element or parts[0].type, | |||||
| # element_type = parts[0].element and 1 or 0 | |||||
| # ) | |||||
| #for part in parts[1:]: | |||||
| for part in parts: | for part in parts: | ||||
| callinfo.addOutParameter( | callinfo.addOutParameter( | ||||
| part.name, | part.name, | ||||
| @@ -88,8 +88,8 @@ class SchemaReader: | |||||
| reader = self.__readerClass() | reader = self.__readerClass() | ||||
| reader.loadDocument(file) | reader.loadDocument(file) | ||||
| schema = XMLSchema() | schema = XMLSchema() | ||||
| if base is not None: | |||||
| schema.setBaseUrl(base) | |||||
| if url is not None: | |||||
| schema.setBaseUrl(url) | |||||
| schema.load(reader) | schema.load(reader) | ||||
| self.__setIncludes(schema) | self.__setIncludes(schema) | ||||
| self.__setImports(schema) | self.__setImports(schema) | ||||
| @@ -16,6 +16,9 @@ class ILogger: | |||||
| return | return | ||||
| def error(self, *args): | def error(self, *args): | ||||
| return | return | ||||
| def setLevel(cls, level): | |||||
| cls.level = level | |||||
| setLevel = classmethod(setLevel) | |||||
| _LoggerClass = ILogger | _LoggerClass = ILogger | ||||
| @@ -24,10 +27,12 @@ class BasicLogger(ILogger): | |||||
| self.msg, self.out = msg, out | self.msg, self.out = msg, out | ||||
| def warning(self, msg, *args): | def warning(self, msg, *args): | ||||
| if self.level < 1: return | |||||
| print >>self, self.WARN, self.msg, | print >>self, self.WARN, self.msg, | ||||
| print >>self, msg %args | print >>self, msg %args | ||||
| WARN = 'WARN' | WARN = 'WARN' | ||||
| def debug(self, msg, *args): | def debug(self, msg, *args): | ||||
| if self.level < 2: return | |||||
| print >>self, self.DEBUG, self.msg, | print >>self, self.DEBUG, self.msg, | ||||
| print >>self, msg %args | print >>self, msg %args | ||||
| DEBUG = 'DEBUG' | DEBUG = 'DEBUG' | ||||
| @@ -43,9 +48,22 @@ class BasicLogger(ILogger): | |||||
| def setBasicLogger(): | def setBasicLogger(): | ||||
| '''Use Basic Logger. | |||||
| ''' | |||||
| setLoggerClass(BasicLogger) | |||||
| BasicLogger.setLevel(0) | |||||
| def setBasicLoggerWARN(): | |||||
| '''Use Basic Logger. | |||||
| ''' | |||||
| setLoggerClass(BasicLogger) | |||||
| BasicLogger.setLevel(1) | |||||
| def setBasicLoggerDEBUG(): | |||||
| '''Use Basic Logger. | '''Use Basic Logger. | ||||
| ''' | ''' | ||||
| setLoggerClass(BasicLogger) | setLoggerClass(BasicLogger) | ||||
| BasicLogger.setLevel(2) | |||||
| def setLoggerClass(loggingClass): | def setLoggerClass(loggingClass): | ||||
| '''Set Logging Class. | '''Set Logging Class. | ||||