Deploying multiple web services i.e. Multiple wsdl files in python

I am creating web services in python using Spyne based on this example . However, all my services are combined into a single wsdl file located at http://localhost:8000/?wsdl. I am looking for another way to deploy each web service separately in one wsdl file, for example. http://localhost:8000/service1/?wsdlandhttp://localhost:8000/service2?wsdl

+4
source share
1 answer

Spyne has a class WsgiMounterfor this:

from spyne.util.wsgi_wrapper import WsgiMounter

app1 = Application([SomeService], tns=tns,
        in_protocol=Soap11(), out_protocol=Soap11())
app2 = Application([SomeOtherService], tns=tns,
        in_protocol=Soap11(), out_protocol=Soap11())
wsgi_app = WsgiMounter({
    'app1': app1,
    'app2': app2,
})

Now you can pass wsgi_appto the Wsgi implementation using the same way that you passed the instance WsgiApplication.

Wsgi , , . - 404.

: https://github.com/plq/spyne/blob/master/examples/multiple_protocols/server.py

, Service . , :

def SomeServiceFactory():
    class SomeService(ServiceBase):
        @rpc(Unicode, _returns=Unicode)
        def echo_string(ctx, string):
            return string
    return SomeService

SomeServiceFactory() Application.

.

app1 = Application([SomeServiceFactory()], tns=tns,
        in_protocol=Soap11(), out_protocol=Soap11())
app2 = Application([SomeServiceFactory()], tns=tns,
        in_protocol=Soap11(), out_protocol=Soap11())

, .

+6

All Articles