我正在尝试使用几种不同的Python SOAP服务器库,但似乎无法获得用于spyne的“ hello world”示例:
https://github.com/arskom/spyne/blob/master/examples/helloworld_soap.py
运行它时,它会启动SOAP服务器,并且可以在http://localhost:7789/?wsdl
的浏览器中成功查看WSDL。但是,当我尝试与suds客户端连接时,出现异常:
Python 2.7.3 (default, Aug 1 2012, 05:14:39)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from suds.client import Client
>>> c = Client('http://localhost:7789/?wsdl')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/acordiner/ve/local/lib/python2.7/site-packages/suds/client.py", line 112, in __init__
self.wsdl = reader.open(url)
File "/home/acordiner/ve/local/lib/python2.7/site-packages/suds/reader.py", line 152, in open
d = self.fn(url, self.options)
File "/home/acordiner/ve/local/lib/python2.7/site-packages/suds/wsdl.py", line 158, in __init__
self.resolve()
File "/home/acordiner/ve/local/lib/python2.7/site-packages/suds/wsdl.py", line 207, in resolve
c.resolve(self)
File "/home/acordiner/ve/local/lib/python2.7/site-packages/suds/wsdl.py", line 661, in resolve
self.resolveheaders(definitions, op)
File "/home/acordiner/ve/local/lib/python2.7/site-packages/suds/wsdl.py", line 725, in resolveheaders
raise Exception, "message'%s', not-found" % mn
Exception: message's0:SomeObject', not-found
我可能做错了什么?我正在使用spyne 2.9.4和suds 0.4。
最佳答案
对此我感到抱歉。
您链接到的示例是:https://github.com/arskom/spyne/blob/ec2bd6feb89fb36915b7266497c177e4c6f78b83/examples/helloworld_soap.py
它用于说明suds错误,该错误已在my own version of suds中修复,但未在主流sud中修复。后来我忘记了将其还原到Spyne主存储库中。
您可以找到relevant commit here。
Suds无法处理名称空间与targetNamespace
不同的传出标头对象。您可以通过设置SomeObject.__namespace__ = 'spyne.examples.hello.soap'
而不是'aaa'
来使您的suds版本起作用。
您也可以只删除在helloworld示例中不适当的传出标头声明。
我希望这有帮助。