def unmarshall_object(vim, obj):
    from suds.mx import Content
    from suds.sax.parser import Parser
    from suds.bindings.document import Document
    binding = Document(vim.client.wsdl)
    marshaller = binding.marshaller()
    content = Content(obj.__class__.__name__, obj)
    marshalled_obj = marshaller.process(content)
    return str(marshalled_obj)
def marshall_response(vim, response):
    from suds.sax.parser import Parser
    from suds.bindings.document import Document
    parser = Parser()
    document = parser.parse(string=response)
    obj = document.getChildren()[0]
    binding = Document(vim.client.wsdl)
    unmarshaller = binding.unmarshaller()
    marshalled_obj = unmarshaller.process(obj, None)
    return vim._parse_object_content(marshalled_obj)
Ejemplo n.º 3
0
 def add_methods(self):
     """ Build method view for service """
     bindings = {
         'document/literal': Document(self),
         'rpc/literal': RPC(self),
         'rpc/encoded': Encoded(self)
     }
     for p in self.service.ports:
         binding = p.binding
         ptype = p.binding.type
         operations = p.binding.type.operations.values()
         for name in [op.name for op in operations]:
             m = SFactory.object('Method')
             m.name = name
             m.location = p.location
             m.binding = SFactory.object('binding')
             op = binding.operation(name)
             m.soap = op.soap
             key = '/'.join((op.soap.style, op.soap.input.body.use))
             m.binding.input = bindings.get(key)
             key = '/'.join((op.soap.style, op.soap.output.body.use))
             m.binding.output = bindings.get(key)
             op = ptype.operation(name)
             m.message = SFactory.object('message')
             m.message.input = op.input
             m.message.output = op.output
             m.qname = ':'.join((p.name, name))
             self.service.methods[m.name] = m
             self.service.methods[m.qname] = m
Ejemplo n.º 4
0
Archivo: wsdl.py Proyecto: uhla/suds-sw
    def add_methods(self, service):
        """ Build method view for service """
        bindings = {
            'document/literal': Document(self),
            'rpc/literal': RPC(self),
            'rpc/encoded': Encoded(self)
        }
        for p in service.ports:
            binding = p.binding
            ptype = p.binding.type
            operations = p.binding.type.operations
            for name in operations.keys():
                for operation in operations[name]:
                    m = Facade('Method')
                    m.name = name
                    m.location = p.location
                    m.binding = Facade('binding')
                    op = binding.operation(name, operation.input.name,
                                           operation.output.name)
                    m.soap = op.soap
                    key = '/'.join((op.soap.style, op.soap.input.body.use))
                    m.binding.input = bindings.get(key)
                    key = '/'.join((op.soap.style, op.soap.output.body.use))
                    m.binding.output = bindings.get(key)

                    p.methods.add(name, m)
Ejemplo n.º 5
0
 def add_methods(self, service):
     """ Build method view for service """
     bindings = {
         'document/literal': Document(self),
         'rpc/literal': RPC(self),
         'rpc/encoded': Encoded(self)
     }
     for p in service.ports:
         binding = p.binding
         ptype = p.binding.type
         operations = p.binding.type.operations.values()
         for name in [op.name for op in operations]:
             m = Facade('Method')
             m.name = name
             m.location = p.location
             m.binding = Facade('binding')
             op = binding.operation(name)
             op.soap.input.policy = self.build_policy(
                 binding, op.soap.input, True)
             op.soap.output.policy = self.build_policy(
                 binding, op.soap.output, False)
             m.soap = op.soap
             key = '/'.join((op.soap.style, op.soap.input.body.use))
             m.binding.input = bindings.get(key)
             key = '/'.join((op.soap.style, op.soap.output.body.use))
             m.binding.output = bindings.get(key)
             op = ptype.operation(name)
             p.methods[name] = m
Ejemplo n.º 6
0
    def marshalled(self, context):
        """Add an authenticator token to the document before it is sent.

        :param context: The current message context.
        """
        body = context.envelope.getChild("Body")
        operation = body[0]

        if operation.name in ("AuthenticateUser", "RegisterAccount"):
            pass
        elif self.authenticator:
            namespace = operation.namespace()
            element = Element("Authenticator", ns=namespace)
            element.setText(self.authenticator)
            operation.insert(element)
        else:
            document = Document(self.client.wsdl)
            method = self.client.service.AuthenticateUser.method
            parameter = document.param_defs(method)[0]
            element = document.mkparam(method, parameter, self.credentials)
            operation.insert(element)
Ejemplo n.º 7
0
    def marshalled(self, context):
        """Add an authenticator token to the document before it is sent.

        :param context: The current message context.
        """
        body = context.envelope.getChild("Body")
        operation = body[0]

        if operation.name in ("AuthenticateUser", "RegisterAccount"):
            pass
        elif self.authenticator:
            namespace = operation.namespace()
            element = Element("Authenticator", ns=namespace)
            element.setText(self.authenticator)
            operation.insert(element)
        else:
            document = Document(self.client.wsdl)
            method = self.client.service.AuthenticateUser.method
            parameter = document.param_defs(method)[0]
            element = document.mkparam(method, parameter, self.credentials)
            operation.insert(element)
Ejemplo n.º 8
0
 def add_methods(self, service):
     """Build method view for service."""
     bindings = {
         "document/literal": Document(self),
         "rpc/literal": RPC(self),
         "rpc/encoded": Encoded(self)}
     for p in service.ports:
         binding = p.binding
         ptype = p.binding.type
         operations = p.binding.type.operations.values()
         for name in (op.name for op in operations):
             m = Facade("Method")
             m.name = name
             m.location = p.location
             m.binding = Facade("binding")
             op = binding.operation(name)
             m.soap = op.soap
             key = "/".join((op.soap.style, op.soap.input.body.use))
             m.binding.input = bindings.get(key)
             key = "/".join((op.soap.style, op.soap.output.body.use))
             m.binding.output = bindings.get(key)
             p.methods[name] = m