我正在试验几个不同的Python SOAP服务器库,我似乎无法让'hello world'示例适用于spyne: 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和泡沫0.4。
答案 0 :(得分:5)
我很抱歉这种混乱。
它用于说明肥皂泡,它在my own version of suds中修复,但在主流泡沫中没有。我后来忘了将它还原回主Spyne存储库。
您可以找到relevant commit here。
Suds无法处理名称空间不同于targetNamespace
的传出标头对象。您可以通过设置SomeObject.__namespace__ = 'spyne.examples.hello.soap'
而不是'aaa'
来使您的suds版本正常工作。
您还可以删除helloworld示例中不合适的传出标头声明。
我希望这会有所帮助。