Ejemplo n.º 1
0
    def _createTypes(self, name, elements):
        elem = b''
        if isinstance(elements, list):
            elem = b'<xsd:complexType name="%sParams">\n' % name
            elem += b'<xsd:sequence>\n'
            elems = b''
            idx = 1
            for e in elements:
                if hasattr(e, '__name__'):
                    elems += b'<xsd:element name="value%d" type="xsd:%s"/>\n' % (
                        idx, complextypes.createPythonType2XMLType(e.__name__))
                else:
                    elems += e.createElement('value%s' % idx) + '\n'
                idx += 1
            elem += elems + b'</xsd:sequence>\n'
            elem += b'</xsd:complexType>\n'
            elem += b'<xsd:element name="%s" type="tns:%sParams"/>\n' % (name,
                                                                         name)
        elif inspect.isclass(elements) and issubclass(elements,
                                                      xmltypes.PrimitiveType):
            elem = elements.createElement(name) + '\n'
        elif hasattr(elements, '__name__'):
            elem += b'<xsd:element name="%s" type="xsd:%s"/>\n' % (
                name, complextypes.createPythonType2XMLType(elements.__name__))

        return elem
Ejemplo n.º 2
0
	def createArray(self,name):
		type = None
		if inspect.isclass(self._type) and not issubclass(self._type,PrimitiveType):
			type = complextypes.createPythonType2XMLType(self._type.__name__)
		else:
			type = self._type.getType(self._type)
		return createArrayXML(name,type,'xsd',self._n)
Ejemplo n.º 3
0
    def _createComplexTypes(self, name, arguments, elements):
        """ Private method that creates complex types for wsdl """
        elem = b''
        if isinstance(elements, dict):
            elem = b'<xsd:complexType name="%sTypes">\n' % name
            elem += b'<xsd:sequence>\n'
            elems = b''
            for e in arguments:
                if isinstance(elements[e], xmltypes.Array):
                    elems += elements[e].createType(e)
                elif issubclass(elements[e], xmltypes.PrimitiveType):
                    elems += elements[e].createElement(e) + '\n'
                elif issubclass(elements[e], complextypes.ComplexType):
                    elems += b'<xsd:element name="%s" type="tns:%s"/>\n' % (
                        e, elements[e].__name__)
                else:
                    elems += b'<xsd:element name="%s" type="xsd:%s"/>\n' % (
                        e,
                        complextypes.createPythonType2XMLType(
                            elements[e].__name__))
            elem += elems + b'</xsd:sequence>\n'
            elem += b'</xsd:complexType>\n'
            elem += b'<xsd:element name="%s" type="tns:%sTypes"/>\n' % (name,
                                                                        name)
        elif issubclass(elements, xmltypes.PrimitiveType):
            elem = elements.createElement(name) + '\n'

        return elem
Ejemplo n.º 4
0
	def _createTypes(self, name, elements):
		elem = b''
		if isinstance(elements,list):
			elem = b'<xsd:complexType name="%sParams">\n'%name
			elem += b'<xsd:sequence>\n'
			elems = b''
			idx = 1
			for e in elements:
				if hasattr(e,'__name__'):
					elems += b'<xsd:element name="value%d" type="xsd:%s"/>\n'%(idx,complextypes.createPythonType2XMLType(e.__name__))
				else:
					elems += e.createElement('value%s'%idx)+'\n'
				idx += 1
			elem += elems+b'</xsd:sequence>\n'
			elem += b'</xsd:complexType>\n'
			elem += b'<xsd:element name="%s" type="tns:%sParams"/>\n'%(name,name)
		elif inspect.isclass(elements) and issubclass(elements,xmltypes.PrimitiveType):
			elem = elements.createElement(name)+'\n'
		elif hasattr(elements,'__name__'):
			elem += b'<xsd:element name="%s" type="xsd:%s"/>\n'%(name,complextypes.createPythonType2XMLType(elements.__name__))

		return elem
Ejemplo n.º 5
0
	def createType(self,name):
		prefix = 'xsd'
		type = None
		if inspect.isclass(self._type) and not issubclass(self._type,PrimitiveType):
			type = complextypes.createPythonType2XMLType(self._type.__name__)
		else:
			type = self._type.getType(self._type)
		maxoccurs = self._n
		complexType = b''
		if self._n == None:
			complexType += b'<%s:element name="%s" type="%s:%s" maxOccurs="unbounded"/>\n'%(prefix,name,prefix,type)
		else:
			complexType += b'<%s:element name="%s" type="%s:%s" maxOccurs="%d"/>\n'%(prefix,name,prefix,type,maxoccurs)
		return complexType
Ejemplo n.º 6
0
	def _createComplexTypes(self, name, arguments, elements):
		elem = b''
		if isinstance(elements,dict):
			elem = b'<xsd:complexType name="%sTypes">\n'%name
			elem += b'<xsd:sequence>\n'
			elems = b''
			for e in arguments:
				if  isinstance(elements[e],xmltypes.Array):
					elems += elements[e].createType(e)
				elif issubclass(elements[e],xmltypes.PrimitiveType):
					elems += elements[e].createElement(e)+'\n'
				else:
					elems += b'<xsd:element name="%s" type="xsd:%s"/>\n'%(e,complextypes.createPythonType2XMLType(elements[e].__name__))
			elem += elems+b'</xsd:sequence>\n'
			elem += b'</xsd:complexType>\n'
			elem += b'<xsd:element name="%s" type="tns:%sTypes"/>\n'%(name,name)
		elif issubclass(elements,xmltypes.PrimitiveType):
			elem = elements.createElement(name)+'\n'

		return elem