Spyneフレームワークとコードのこの例の部分を使用して、python3でSOAPサービスをホストしようとしています:
class HelloWorldService(ServiceBase):
@srpc(Unicode, Integer, _returns=Iterable(Unicode))
def say_hello(name, times):
for i in range(times):
yield 'Hello, %s' % name
application = Application([HelloWorldService],
tns='spyne.examples.hello',
in_protocol=Soap11(),
out_protocol=Soap11()
)
if __name__ == '__main__':
# You can use any Wsgi server. Here, we chose
# Python's built-in wsgi server but you're not
# supposed to use it in production.
from wsgiref.simple_server import make_server
wsgi_app = WsgiApplication(application)
server = make_server('0.0.0.0', 8000, wsgi_app)
server.serve_forever()
機能していますが、使用する名前空間は 1 つだけです。
tns='spyne.examples.hello'
この行で複数のサービスを定義できます。
application = Application([HelloWorldService, OtherService1, OtherService2]
しかし、サービスごとに異なる名前空間を定義することは可能ですか? このようなものは機能しません:
tns=['spyne.examples.hello', 'http://other.service1', 'http://other.service2']