python - spyne SOAP 服务器的 Hello world 示例

标签 python soap suds spyne

我正在试验几个不同的 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 和 suds 0.4。

最佳答案

对于造成的困惑,我深表歉意。

您链接到的示例是这样的:https://github.com/arskom/spyne/blob/ec2bd6feb89fb36915b7266497c177e4c6f78b83/examples/helloworld_soap.py

它被用来说明泡沫错误,该错误已在 my own version of suds 中修复,但不是在主流泡沫中。我后来忘记在主 Spyne 存储库中将其还原。

您可以找到 relevant commit here .

Suds 无法处理命名空间不同于targetNamespace 的传出 header 对象。您可以通过设置 SomeObject.__namespace__ = 'spyne.examples.hello.soap' 而不是 'aaa' 让您的 suds 版本工作。

您也可以只删除在 helloworld 示例中不合适的传出 header 声明。

希望对您有所帮助。

关于python - spyne SOAP 服务器的 Hello world 示例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15131293/

相关文章:

python - 使用 Databricks 中的 PySpark 在 Azure DataLake 中使用 partitionBy 和覆盖策略

c# - 从 SOAP 请求中读取 XML 属性到 WCF 服务

grails - java.lang.LinkageError: “javax/activation/DataHandler”

python - 列出 Web 服务 UpdateList 失败并显示 "Attempted to use an object that has ceased to exist"

python - 通过Python suds在JIRA中创建问题时设置受让人字段

python - 使用 Python/SUDS 设置 IncludeExceptionDetailInFaults

python - 使用 Python 多处理运行 .exe 文件时出错

python - Django - 查看,url 怪异

Python 3 多行打印更新

java - 自定义服务器 SOAP 故障字符串