Exemplo n.º 1
0
def main(argv):
    observer = log.PythonLoggingObserver('twisted')
    log.startLoggingWithObserver(observer.emit, setStdout=False)

    wsgi_application = wsgi.Application(application)

    return run_twisted([(wsgi_application, url)], port)
Exemplo n.º 2
0
def main(argv):
    observer = log.PythonLoggingObserver('twisted')
    log.startLoggingWithObserver(observer.emit, setStdout=False)

    wsgi_application = wsgi.Application(application)

    return run_twisted( [ (wsgi_application, url) ], port )
Exemplo n.º 3
0
    @rpc(SOAPRequest, _returns=Integer)
    def get_integers_count(self, req):
        return self.max

    @rpc(_returns=String)
    def name(self):
        return self.__class__.__name__

    @rpc(NestedObject, _returns=NestedObject)
    def get_nested(self, complex):
        retval = NestedObject()
        retval.date_time = datetime.now()

        retval.ro = ReturnObject()
        i = 5
        retval.ro.byone = i
        retval.ro.bytwo = i * 2
        retval.ro.bythree = i * 3
        retval.ro.byfour = i * 4
        retval.ro.byfive = i * 5
        retval.arr = ['asd097n09a', 'askdj0n3t']

        return retval


apps = [(Application([HelloWorldService],
                     'HelloWorldService.HelloWorldService'), 'svc')]

if __name__ == '__main__':
    sys.exit(run_twisted(apps, 7789))
Exemplo n.º 4
0
from soaplib.serializers.primitive import String, Integer, Array
from soaplib.wsgi import Application
from soaplib.util.server import run_twisted


'''
This is the HelloWorld example running in the twisted framework.
'''

class HelloWorldService(DefinitionBase):
    @rpc(String, Integer, _returns=Array(String))
    def say_hello(self, name, times):
        '''
        Docstrings for service methods appear as documentation in the wsdl
        <b>what fun</b>
        @param name the name to say hello to
        @param the number of times to say hello
        @return the completed array
        '''
        results = []
        for i in range(0, times):
            results.append('Hello, %s' % name)
        return results


if __name__=='__main__':
    app=Application([HelloWorldService], 'tns')
    print 'listening on 0.0.0.0:7789'
    print 'wsdl is at: http://0.0.0.0:7789/SOAP/?wsdl'
    run_twisted( ( (app, "SOAP"),), 7789)