[英]Python soaplib “Hello World” program - Parameters and types not showing up on client
I'm attempting to run the soaplib Hello World program: 我正在尝试运行soaplib Hello World程序:
import soaplib
from soaplib.core.service import rpc, DefinitionBase
from soaplib.core.model.primitive import String, Integer
from soaplib.core.server import wsgi
from soaplib.core.model.clazz import Array
from soaplib.core.service import soap
class HelloWorldService(DefinitionBase):
@soap(String,Integer,_returns=Array(String))
def say_hello(self,name,times):
results = []
for i in range(0,times):
results.append('Hello, %s'%name)
import pdb; pdb.set_trace()
return results
if __name__=='__main__':
try:
from wsgiref.simple_server import make_server
soap_application = soaplib.core.Application([HelloWorldService], 'tns')
wsgi_application = wsgi.Application(soap_application)
server = make_server('localhost', 7789, wsgi_application)
server.serve_forever()
except ImportError:
print "Error: example server code requires Python >= 2.5"
I was having problems connecting to the service, both using a browser and a simple suds client. 我在使用浏览器和简单的suds客户端连接到服务时遇到问题。 I used the code from the top answer here to get a list of the methods of my little webservice, as well as they're parameters and types.
我从此处的最高答案中使用了代码,以获取我的小型Web服务方法的列表以及它们的参数和类型。 The result I got wasn't particularly encouraging:
我得到的结果并不特别令人鼓舞:
say_hello(None: say_hello)
So it appears that the reason that I was unable to call the function properly is that it's parameters and types do not appear to register: However, as far as I can tell this should not be the case. 因此看来,我无法正确调用该函数的原因是它的参数和类型似乎没有注册:但是,据我所知,事实并非如此。 I'm particularly dumbfounded as this is the hello world program presented on the soaplib website.
我特别傻眼,因为这是soaplib网站上介绍的hello world程序。
I've searched both here and elsewhere, but I don't seem to find a similar problem anywhere. 我在这里和其他地方都进行了搜索,但似乎在任何地方都找不到类似的问题。 Any thoughts?
有什么想法吗?
I've tried the soaplib "Hello world" example . 我已经尝试过soaplib“ Hello world”示例 。 It works if you add
from soaplib.core.service import soap
as you did. 如果您像以前那样
from soaplib.core.service import soap
添加from soaplib.core.service import soap
它将起作用。
I've installed both soaplib
and suds
using pip install
. 我已经安装了
soaplib
和suds
使用pip install
。
$ pip freeze | grep -e'soaplib\|suds'
soaplib==2.0.0-beta2
suds==0.4
It seems soaplib
was refactored to rpclib
which was replaced by spyne
. 似乎
soaplib
被重构为rpclib
,被spyne
取代。 It doesn't provide confidence in the project. 它对项目没有信心。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.