Spyne

raw JSON →
2.14.0 verified Fri May 01 auth: no python maintenance

A transport and architecture agnostic RPC library focusing on exposing public services with a well-defined API. Current version 2.14.0. Release cadence is irregular; last major release was 2020, with minor patches since.

pip install spyne
error ImportError: cannot import name 'Application' from 'spyne'
cause Spyne version older than 2.10 where Application was not re-exported.
fix
Install spyne>=2.10: 'pip install spyne>=2.10' or import from 'spyne.application' for older versions.
error AttributeError: module 'spyne' has no attribute 'rpc'
cause Using a very old version (pre-2.10) or a broken installation.
fix
Upgrade to spyne>=2.10: 'pip install --upgrade spyne'.
error TypeError: __init__() got an unexpected keyword argument '_returns'
cause The '_returns' parameter for @rpc was added in Spyne 2.12. Using an older version.
fix
Upgrade to spyne>=2.12 or use 'returns' (without underscore) for older versions.
breaking Spyne 2.13 dropped support for Python 2.7 and Python 3.4. Use Python 3.5+.
fix Upgrade Python environment to 3.5 or higher.
deprecated The 'spyne.application' module is deprecated; import directly from 'spyne'.
fix Replace 'from spyne.application import Application' with 'from spyne import Application'.
gotcha WsgiApplication is deprecated in favor of WsgiApplication (note: same name) but the import location changed; use 'from spyne.server.wsgi import WsgiApplication'.
fix Import from 'spyne.server.wsgi' instead of 'spyne.server.wsgi' (it's the same path but verify spelling: WsgiApplication).
gotcha Spyne does not officially support async/await. Using asyncio with Spyne may cause unpredictable behavior.
fix Use synchronous WSGI/HTTP servers; consider a different library for async RPC.

Create a minimal SOAP service with Spyne 2.14.

from spyne import Application, rpc, ServiceBase, Iterable, Integer, Unicode
from spyne.protocol.soap import Soap11
from spyne.server.wsgi import WsgiApplication

class HelloWorldService(ServiceBase):
    @rpc(Unicode, _returns=Unicode)
    def say_hello(ctx, name):
        return 'Hello, %s!' % name

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

if __name__ == '__main__':
    from wsgiref.simple_server import make_server
    server = make_server('0.0.0.0', 8000, WsgiApplication(application))
    server.serve_forever()