1
我正在嘗試使用Spyne創建SOAP Web服務。基於簡單Hello example,我要創建2級不同的服務:使用Spyne創建多個服務
from spyne.application import Application
from spyne.protocol.soap import Soap11
from spyne.server.wsgi import WsgiApplication
from spyne.decorator import rpc
from spyne.service import ServiceBase
from spyne.model.complex import Iterable
from spyne.model.primitive import Unicode
class HelloWorldService(ServiceBase):
@rpc(Unicode, _returns=Iterable(Unicode))
def say_hello(ctx, name):
return [u'Hello, %s' % name]
class HelloWorldService1(ServiceBase):
@rpc(Unicode, _returns=Iterable(Unicode))
def say_hello1(ctx, name):
return [u'Hello, %s' % name]
if __name__=='__main__':
from wsgiref.simple_server import make_server
application = Application([HelloWorldService, HelloWorldService1],
'spyne.examples.hello.soap',
in_protocol=Soap11(validator='lxml'),
out_protocol=Soap11()
)
wsgi_application = WsgiApplication(application)
server = make_server('127.0.0.1', 8000, wsgi_application)
server.serve_forever()
然而,當我嘗試用肥皂水使用這些服務:
from suds.client import Client
client = Client('http://localhost:8000/?wsdl')
print client
只有一個可用的服務:
Service (HelloWorldService) tns="spyne.examples.hello.soap"
Prefixes (1)
ns0 = "spyne.examples.hello.soap"
Ports (1):
(Application)
Methods (1):
say_hello(xs:string name, xs:integer times,)
Types (3):
say_hello
say_helloResponse
stringArray
所以,我不知道是否有什麼我錯過了。此外,如果可能的話,誰能告訴我如何在Spyne中創建多個服務,每個服務都有自己的wsdl文件。
你是對的,我的服務客戶似乎保留舊服務的副本,問題在我清除緩存後解決。 –