这个问题与: Python SOAP服务器/客户端有关
在使用python的soap的情况下,建议使用soaplib(http://wiki.github.com/jkp/soaplib)作为soap服务器和suds (https://fedorahosted.org/suds/)作为soap客户端.我的目标是在python中创建可由多个客户端(java等)使用的soap服务.我尝试了soaplib的HelloWorld示例(http://trac.optio.webfactional.com/wiki/HelloWorld).当客户端也使用soaplib时,它运行良好.
然后,我尝试使用suds作为消费HelloWorld服务的客户端,它失败了. - 为什么会这样?soaplib服务器是否有不同客户端使用的问题?
这里是服务器的代码:
from soaplib.wsgi_soap import SimpleWSGISoapApp
from soaplib.service import soapmethod
from soaplib.serializers.primitive import String, Integer, Arraycode
class HelloWorldService(SimpleWSGISoapApp):
@soapmethod(String,Integer,_returns=Array(String))
def say_hello(self,name,times):
results = []
for i in range(0,times):
results.append('Hello, %s'%name)
return results
if __name__=='__main__':
from cherrypy.wsgiserver import CherryPyWSGIServer
#from cherrypy._cpwsgiserver import CherryPyWSGIServer
# this example uses CherryPy2.2, use cherrypy.wsgiserver.CherryPyWSGIServer for CherryPy 3.0
server = CherryPyWSGIServer(('localhost',7789),HelloWorldService())
server.start()
Run Code Online (Sandbox Code Playgroud)
这是soaplib客户端:
from soaplib.client import make_service_client
from SoapServerTest_1 import HelloWorldService
client = …Run Code Online (Sandbox Code Playgroud)