我正在尝试使用 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()
它正在工作,但它只使用一个命名空间。
tns='spyne.examples.hello'
我可以在这一行定义多个服务:
application = Application([HelloWorldService, OtherService1, OtherService2]
但是是否可以为每个服务定义不同的命名空间?像这样的东西不起作用:
tns=['spyne.examples.hello', 'http://other.service1', 'http://other.service2']