Esempio n. 1
0
 def resolve(self, definitions):
     """
     Resolve named references to other WSDL objects.
     @param definitions: A definitions object.
     @type definitions: L{Definitions}
     """
     for op in self.operations.values():
         if op.input is None:
             op.input = Message(Element('no-input'), definitions)
         else:
             qref = qualify(op.input, self.root, definitions.tns)
             msg = definitions.messages.get(qref)
             if msg is None:
                 raise Exception("msg '%s', not-found" % op.input)
             else:
                 op.input = msg
         if op.output is None:
             op.output = Message(Element('no-output'), definitions)
         else:
             qref = qualify(op.output, self.root, definitions.tns)
             msg = definitions.messages.get(qref)
             if msg is None:
                 raise Exception("msg '%s', not-found" % op.output)
             else:
                 op.output = msg
         for f in op.faults:
             qref = qualify(f.message, self.root, definitions.tns)
             msg = definitions.messages.get(qref)
             if msg is None:
                 raise Exception, "msg '%s', not-found" % f.message
             f.message = msg
Esempio n. 2
0
 def body(self, content):
     """
     Build the B{<Body/>} for an soap outbound message.
     @param content: The body content.
     @type content: L{Element}
     @return: the soap body fragment.
     @rtype: L{Element}
     """
     body = Element('Body', ns=envns)
     body.append(content)
     return body
Esempio n. 3
0
 def header(self, content):
     """
     Build the B{<Body/>} for an soap outbound message.
     @param content: The header content.
     @type content: L{Element}
     @return: the soap body fragment.
     @rtype: L{Element}
     """
     header = Element('Header', ns=envns)
     header.append(content)
     return header
Esempio n. 4
0
 def body(self, content):
     """
     Build the B{<Body/>} for an soap outbound message.
     @param content: The body content.
     @type content: L{Element}
     @return: the soap body fragment.
     @rtype: L{Element}
     """
     body = Element('Body', ns=envns)
     body.append(content)
     return body
Esempio n. 5
0
 def xml(self):
     """
     Get xml representation of the object.
     @return: The root node.
     @rtype: L{Element}
     """
     root = Element('Security', ns=wssens)
     root.set('mustUnderstand', str(self.mustUnderstand).lower())
     for t in self.tokens:
         root.append(t.xml())
     return root
Esempio n. 6
0
 def header(self, content):
     """
     Build the B{<Body/>} for an soap outbound message.
     @param content: The header content.
     @type content: L{Element}
     @return: the soap body fragment.
     @rtype: L{Element}
     """
     header = Element('Header', ns=envns)
     header.append(content)
     return header
Esempio n. 7
0
 def add(self, root):
     """
     Add an <xs:import/> to the specified schema root.
     @param root: A schema root.
     @type root: L{Element}
     """
     node = Element('import', ns=self.xsdns)
     node.set('namespace', self.ns)
     if self.location is not None:
         node.set('schemaLocation', self.location)
     log.debug('%s inserted', node)
     root.insert(node) 
Esempio n. 8
0
 def xml(self):
     root = Element("Timestamp", ns=wsuns)
     created = Element('Created', ns=wsuns)
     created.setText(str(UTC(self.created)))
     expires = Element('Expires', ns=wsuns)
     expires.setText(str(UTC(self.expires)))
     root.append(created)
     root.append(expires)
     return root
Esempio n. 9
0
 def startElement(self, name, attrs):
     top = self.top()
     node = Element(unicode(name), parent=top)
     for a in attrs.getNames():
         n = unicode(a)
         v = unicode(attrs.getValue(a))
         attribute = Attribute(n,v)
         if self.mapPrefix(node, attribute):
             continue
         node.append(attribute)
     node.charbuffer = []
     top.append(node)
     self.push(node)
Esempio n. 10
0
 def startElement(self, name, attrs):
     top = self.top()
     node = Element(unicode(name), parent=top)
     for a in attrs.getNames():
         n = unicode(a)
         v = unicode(attrs.getValue(a))
         attribute = Attribute(n, v)
         if self.mapPrefix(node, attribute):
             continue
         node.append(attribute)
     node.charbuffer = []
     top.append(node)
     self.push(node)
Esempio n. 11
0
 def node(self, content):
     #
     # Create an XML node and namespace qualify as defined
     # by the schema (elementFormDefault).
     #
     ns = content.type.namespace()
     if content.type.form_qualified:
         node = Element(content.tag, ns=ns)
         node.addPrefix(ns[0], ns[1])
     else:
         node = Element(content.tag)
     self.encode(node, content)
     log.debug('created - node:\n%s', node)
     return node
Esempio n. 12
0
 def apply(self, root):
     """
     Apply the import (rule) to the specified schema.
     If the schema does not already contain an import for the
     I{namespace} specified here, it is added.
     @param root: A schema root.
     @type root: L{Element}
     """
     if not self.filter.match(root, self.ns):
         return
     if self.exists(root):
         return
     node = Element('import', ns=self.xsdns)
     node.set('namespace', self.ns)
     if self.location is not None:
         node.set('schemaLocation', self.location)
     log.debug('inserting: %s', node)
     root.insert(node)
Esempio n. 13
0
 def __init__(self, schema, name):
     """
     @param schema: The containing schema.
     @type schema: L{schema.Schema}
     """
     root = Element(name)
     SchemaObject.__init__(self, schema, root)
     self.name = name
     self.nillable = True
Esempio n. 14
0
 def node(self, content):
     """
     Create and return an XML node.
     @param content: The content for which proccessing has been suspended.
     @type content: L{Object}
     @return: An element.
     @rtype: L{Element}
     """
     return Element(content.tag)
Esempio n. 15
0
    def build_soap_client(self):
        if self.endpoint is None:
            self.endpoint = self.determineStack()

        self.authObj = {'oAuth' : {'oAuthToken' : self.internalAuthToken}}
        self.authObj['attributes'] = { 'oAuth' : { 'xmlns' : 'http://exacttarget.com' }}

        self.soap_client = et_suds.client.Client(self.wsdl_file_url, faults=False, cachingpolicy=1)
        self.soap_client.set_options(location=self.endpoint)

        element_oAuth = Element('oAuth', ns=('etns', 'http://exacttarget.com'))
        element_oAuthToken = Element('oAuthToken').setText(self.internalAuthToken)
        element_oAuth.append(element_oAuthToken)
        self.soap_client.set_options(soapheaders=(element_oAuth))

        security = et_suds.wsse.Security()
        token = et_suds.wsse.UsernameToken('*', '*')
        security.tokens.append(token)
        self.soap_client.set_options(wsse=security)
Esempio n. 16
0
 def autoblend(self):
     """
     Ensure that all schemas within the collection
     import each other which has a blending effect.
     @return: self
     @rtype: L{SchemaCollection}
     """
     namespaces = self.namespaces.keys()
     for s in self.children:
         for ns in namespaces:
             tns = s.root.get('targetNamespace')
             if  tns == ns:
                 continue
             for imp in s.root.getChildren('import'):
                 if imp.get('namespace') == ns:
                     continue
             imp = Element('import', ns=Namespace.xsdns)
             imp.set('namespace', ns)
             s.root.append(imp)
     return self
Esempio n. 17
0
 def __init__(self, name, resolved):
     """
     @param name: The part name.
     @type name: str
     @param resolved: The part type.
     @type resolved: L{et_suds.xsd.sxbase.SchemaObject}
     """
     root = Element('element', ns=Namespace.xsdns)
     SchemaElement.__init__(self, resolved.schema, root)
     self.__resolved = resolved
     self.name = name
     self.form_qualified = False
Esempio n. 18
0
 def document(self, wrapper):
     """
     Get the document root.  For I{document/literal}, this is the
     name of the wrapper element qualifed by the schema tns.
     @param wrapper: The method name.
     @type wrapper: L{xsd.sxbase.SchemaObject}
     @return: A root element.
     @rtype: L{Element}
     """
     tag = wrapper[1].name
     ns = wrapper[1].namespace('ns0')
     d = Element(tag, ns=ns)
     return d
Esempio n. 19
0
 def envelope(self, header, body):
     """
     Build the B{<Envelope/>} for an soap outbound message.
     @param header: The soap message B{header}.
     @type header: L{Element}
     @param body: The soap message B{body}.
     @type body: L{Element}
     @return: The soap envelope containing the body and header.
     @rtype: L{Element}
     """
     env = Element('Envelope', ns=envns)
     env.addPrefix(Namespace.xsins[0], Namespace.xsins[1])
     env.append(header)
     env.append(body)
     return env
Esempio n. 20
0
 def add_operations(self, root, definitions):
     """ Add <operation/> children """
     dsop = Element('operation', ns=soapns)
     for c in root.getChildren('operation'):
         op = Facade('Operation')
         op.name = c.get('name')
         sop = c.getChild('operation', default=dsop)
         soap = Facade('soap')
         soap.action = '"%s"' % sop.get('soapAction', default='')
         soap.style = sop.get('style', default=self.soap.style)
         soap.input = Facade('Input')
         soap.input.body = Facade('Body')
         soap.input.headers = []
         soap.output = Facade('Output')
         soap.output.body = Facade('Body')
         soap.output.headers = []
         op.soap = soap
         input = c.getChild('input')
         if input is None:
             input = Element('input', ns=wsdlns)
         body = input.getChild('body')
         self.body(definitions, soap.input.body, body)
         for header in input.getChildren('header'):
             self.header(definitions, soap.input, header)
         output = c.getChild('output')
         if output is None:
             output = Element('output', ns=wsdlns)
         body = output.getChild('body')
         self.body(definitions, soap.output.body, body)
         for header in output.getChildren('header'):
             self.header(definitions, soap.output, header)
         faults = []
         for fault in c.getChildren('fault'):
             sf = fault.getChild('fault')
             if sf is None:
                 continue
             fn = fault.get('name')
             f = Facade('Fault')
             f.name = sf.get('name', default=fn)
             f.use = sf.get('use', default='literal')
             faults.append(f)
         soap.faults = faults
         self.operations[op.name] = op
Esempio n. 21
0
 def method(self, method):
     """
     Get the document root.  For I{rpc/(literal|encoded)}, this is the
     name of the method qualifed by the schema tns.
     @param method: A service method.
     @type method: I{service.Method}
     @return: A root element.
     @rtype: L{Element}
     """
     ns = method.soap.input.body.namespace
     if ns[0] is None:
         ns = ('ns0', ns[1])
     method = Element(method.name, ns=ns)
     return method
Esempio n. 22
0
 def build_schema(self):
     """ Process L{Types} objects and create the schema collection """
     container = SchemaCollection(self)
     for t in [t for t in self.types if t.local()]:
         for root in t.contents():
             schema = Schema(root, self.url, self.options, container)
             container.add(schema)
     if not len(container): # empty
         root = Element.buildPath(self.root, 'types/schema')
         schema = Schema(root, self.url, self.options, container)
         container.add(schema)
     self.schema = container.load(self.options)
     for s in [t.schema() for t in self.types if t.imported()]:
         self.schema.merge(s)
     return self.schema
Esempio n. 23
0
 def build_schema(self):
     """ Process L{Types} objects and create the schema collection """
     container = SchemaCollection(self)
     for t in [t for t in self.types if t.local()]:
         for root in t.contents():
             schema = Schema(root, self.url, self.options, container)
             container.add(schema)
     if not len(container):  # empty
         root = Element.buildPath(self.root, 'types/schema')
         schema = Schema(root, self.url, self.options, container)
         container.add(schema)
     self.schema = container.load(self.options)
     for s in [t.schema() for t in self.types if t.imported()]:
         self.schema.merge(s)
     return self.schema
Esempio n. 24
0
 def xml(self):
     """
     Get xml representation of the object.
     @return: The root node.
     @rtype: L{Element}
     """
     root = Element('Security', ns=wssens)
     root.set('mustUnderstand', str(self.mustUnderstand).lower())
     for t in self.tokens:
         root.append(t.xml())
     return root
Esempio n. 25
0
 def envelope(self, header, body):
     """
     Build the B{<Envelope/>} for an soap outbound message.
     @param header: The soap message B{header}.
     @type header: L{Element}
     @param body: The soap message B{body}.
     @type body: L{Element}
     @return: The soap envelope containing the body and header.
     @rtype: L{Element}
     """
     env = Element('Envelope', ns=envns)
     env.addPrefix(Namespace.xsins[0], Namespace.xsins[1])
     env.append(header)
     env.append(body)
     return env
Esempio n. 26
0
 def add(self, root):
     """
     Add an <xs:import/> to the specified schema root.
     @param root: A schema root.
     @type root: L{Element}
     """
     node = Element('import', ns=self.xsdns)
     node.set('namespace', self.ns)
     if self.location is not None:
         node.set('schemaLocation', self.location)
     log.debug('%s inserted', node)
     root.insert(node)
Esempio n. 27
0
 def node(self, content):
     #
     # Create an XML node and namespace qualify as defined
     # by the schema (elementFormDefault).
     #
     ns = content.type.namespace()
     if content.type.form_qualified:
         node = Element(content.tag, ns=ns)
         node.addPrefix(ns[0], ns[1])
     else:
         node = Element(content.tag)
     self.encode(node, content)
     log.debug('created - node:\n%s', node)
     return node
Esempio n. 28
0
 def apply(self, root):
     """
     Apply the import (rule) to the specified schema.
     If the schema does not already contain an import for the
     I{namespace} specified here, it is added.
     @param root: A schema root.
     @type root: L{Element}
     """
     if not self.filter.match(root, self.ns):
         return
     if self.exists(root):
         return
     node = Element('import', ns=self.xsdns)
     node.set('namespace', self.ns)
     if self.location is not None:
         node.set('schemaLocation', self.location)
     log.debug('inserting: %s', node)
     root.insert(node)
Esempio n. 29
0
 def add_operations(self, root, definitions):
     """ Add <operation/> children """
     dsop = Element('operation', ns=soapns)
     for c in root.getChildren('operation'):
         op = Facade('Operation')
         op.name = c.get('name')
         sop = c.getChild('operation', default=dsop)
         soap = Facade('soap')
         soap.action = '"%s"' % sop.get('soapAction', default='')
         soap.style = sop.get('style', default=self.soap.style)
         soap.input = Facade('Input')
         soap.input.body = Facade('Body')
         soap.input.headers = []
         soap.output = Facade('Output')
         soap.output.body = Facade('Body')
         soap.output.headers = []
         op.soap = soap
         input = c.getChild('input')
         if input is None:
             input = Element('input', ns=wsdlns)
         body = input.getChild('body')
         self.body(definitions, soap.input.body, body)
         for header in input.getChildren('header'):
             self.header(definitions, soap.input, header)
         output = c.getChild('output')
         if output is None:
             output = Element('output', ns=wsdlns)
         body = output.getChild('body')
         self.body(definitions, soap.output.body, body)
         for header in output.getChildren('header'):
             self.header(definitions, soap.output, header)
         faults = []
         for fault in c.getChildren('fault'):
             sf = fault.getChild('fault')
             if sf is None:
                 continue
             fn = fault.get('name')
             f = Facade('Fault')
             f.name = sf.get('name', default=fn)
             f.use = sf.get('use', default='literal')
             faults.append(f)
         soap.faults = faults
         self.operations[op.name] = op
Esempio n. 30
0
 def __init__(self, root=None):
     Element.__init__(self, 'document')
     if root is not None:
         self.append(root)
Esempio n. 31
0
 def __init__(self, content):
     Element.__init__(self, content.name, content.parent)
     self.__content = content
Esempio n. 32
0
 def create(cls, definitions):
     root = Element('types', ns=wsdlns)
     definitions.root.insert(root)
     return Types(root, definitions)
Esempio n. 33
0
 def xml(self):
     root = Element("Timestamp", ns=wsuns)
     created = Element('Created', ns=wsuns)
     created.setText(str(UTC(self.created)))
     expires = Element('Expires', ns=wsuns)
     expires.setText(str(UTC(self.expires)))
     root.append(created)
     root.append(expires)
     return root
Esempio n. 34
0
 def xml(self):
     """
     Get xml representation of the object.
     @return: The root node.
     @rtype: L{Element}
     """
     root = Element('UsernameToken', ns=wssens)
     u = Element('Username', ns=wssens)
     u.setText(self.username)
     root.append(u)
     p = Element('Password', ns=wssens)
     p.setText(self.password)
     root.append(p)
     if self.nonce is not None:
         n = Element('Nonce', ns=wssens)
         n.setText(self.nonce)
         root.append(n)
     if self.created is not None:
         n = Element('Created', ns=wsuns)
         n.setText(str(UTC(self.created)))
         root.append(n)
     return root
Esempio n. 35
0
 def __init__(self, root=None):
     Element.__init__(self, 'document')
     if root is not None:
         self.append(root)
Esempio n. 36
0
 def xml(self):
     """
     Get xml representation of the object.
     @return: The root node.
     @rtype: L{Element}
     """
     root = Element('UsernameToken', ns=wssens)
     u = Element('Username', ns=wssens)
     u.setText(self.username)
     root.append(u)
     p = Element('Password', ns=wssens)
     p.setText(self.password)
     root.append(p)
     if self.nonce is not None:
         n = Element('Nonce', ns=wssens)
         n.setText(self.nonce)
         root.append(n)
     if self.created is not None:
         n = Element('Created', ns=wsuns)
         n.setText(str(UTC(self.created)))
         root.append(n)
     return root