File: codegen.py

package info (click to toggle)
spyne 2.14.0-8
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,968 kB
  • sloc: python: 35,938; xml: 3,140; sh: 137; makefile: 135; ruby: 19
file content (37 lines) | stat: -rwxr-xr-x 873 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python

import logging
logging.basicConfig(level=logging.DEBUG)

from spyne import Application, rpc, ServiceBase, \
    Integer, Unicode

from spyne import Iterable

from spyne.protocol.soap import Soap11

from spyne.server.twisted import TwistedWebResource

from twisted.internet import reactor
from twisted.web.server import Site

class HelloWorldService(ServiceBase):
    @rpc(Unicode, Integer, _returns=Iterable(Unicode))
    def say_hello(ctx, name, times):
        for i in range(times):
            yield 'Hello, %s' % name

application = Application([HelloWorldService],
    tns='spyne.examples.hello',
    in_protocol=Soap11(validator='lxml'),
    out_protocol=Soap11()
)

if __name__ == '__main__':
    resource = TwistedWebResource(application)
    site = Site(resource)

    reactor.listenTCP(8000, site, interface='0.0.0.0')
    reactor.run()