Last active
April 7, 2017 17:26
-
-
Save DuqueDeTuring/ff113e4b82c87bb9ce746ef0c998c3f2 to your computer and use it in GitHub Desktop.
Python SOAP example using spyne
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.wsgi import WsgiApplication | |
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__': | |
from wsgiref.simple_server import make_server | |
wsgi_app = WsgiApplication(application) | |
server = make_server('0.0.0.0', 8000, wsgi_app) | |
server.serve_forever() | |
# https://pypi.python.org/pypi/ladon |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment