Python 有哪些 SOAP 客户端库,它们的文档在哪里?
我以前从未使用过 SOAP ,而且我对 Python 还算陌生。 我这样做是为了让自己熟悉这两种技术。 我已经安装了 SOAPlib 并且我尝试阅读他们的 Client 文档,但我不太理解它。 还有什么我可以研究的更适合作为 Python 的 SOAP 客户端库吗?
编辑:以防万一它有帮助,我正在使用 Python 2.6。
I've never used SOAP before and I'm sort of new to Python. I'm doing this to get myself acquainted with both technologies. I've installed SOAPlib and I've tried to read their Client documentation, but I don't understand it too well. Is there anything else I can look into which is more suited for being a SOAP Client library for Python?
Edit: Just in case it helps, I'm using Python 2.6.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(14)
更新(2016):
如果您只需要 SOAP 客户端,有一个维护良好的库,名为 zeep。 它支持 Python 2 和 3 :)
更新:
除了上面提到的内容之外,我还将参考 Python WebServices 页面始终保持最新,包含 SOAP 和所有其他 Web 服务类型的所有积极维护和推荐的模块。
不幸的是,目前我不认为存在“最好的”Python SOAP 库。 每个可用的主流都有其自身的优点和缺点。
较旧的库:
SOAPy:是“最好的”,但不再维护。 不适用于 Python 2.5+
ZSI:使用起来非常痛苦,而且开发速度很慢。 有一个名为“SOAPpy”的模块,它与 SOAPy(上面)不同。
“较新”的库:
SUDS:非常 Pythonic,并且易于创建使用 WSDL 的 SOAP 客户端。 创建 SOAP 服务器稍微困难一些。 (此包不适用于 Python3。对于 Python3,请参阅 SUDS-py3)
SUDS-py3:SUDS 的 Python3 版本
spyne:创建服务器很容易,创建客户端有点困难。 文档有些缺乏。
ladon:创建服务器很像在soaplib中(使用装饰器)。 Ladon 同时公开了比 SOAP 更多的接口,无需额外的用户代码。
pysimplesoap:非常轻量级,但对客户端和服务器都很有用 - 包括 web2py 服务器集成随 web2py 一起提供。
其中,我个人只使用过SUDS,并且非常喜欢它。
Update (2016):
If you only need SOAP client, there is well maintained library called zeep. It supports both Python 2 and 3 :)
Update:
Additionally to what is mentioned above, I will refer to Python WebServices page which is always up-to-date with all actively maintained and recommended modules to SOAP and all other webservice types.
Unfortunately, at the moment, I don't think there is a "best" Python SOAP library. Each of the mainstream ones available has its own pros and cons.
Older libraries:
SOAPy: Was the "best," but no longer maintained. Does not work on Python 2.5+
ZSI: Very painful to use, and development is slow. Has a module called "SOAPpy", which is different than SOAPy (above).
"Newer" libraries:
SUDS: Very Pythonic, and easy to create WSDL-consuming SOAP clients. Creating SOAP servers is a little bit more difficult. (This package does not work with Python3. For Python3 see SUDS-py3)
SUDS-py3: The Python3 version of SUDS
spyne: Creating servers is easy, creating clients a little bit more challenging. Documentation is somewhat lacking.
ladon: Creating servers is much like in soaplib (using a decorator). Ladon exposes more interfaces than SOAP at the same time without extra user code needed.
pysimplesoap: very lightweight but useful for both client and server - includes a web2py server integration that ships with web2py.
Of the above, I've only used SUDS personally, and I liked it a lot.
我遵循了这个问题的其他答案的建议,并尝试了 SUDS 。 在“愤怒地”使用它之后,我必须同意:SUDS 非常好! 强烈推荐!
我确实在从代理后面调用基于 HTTPS 的 Web 服务时遇到了麻烦。 在撰写本文时,这会影响使用
urllib2
的所有 Python Web 服务客户端,因此我将在此处记录该解决方案。随 python 2.6.2 及更低版本一起提供的 urllib2 模块不会向 HTTPS-over-HTTP 代理会话的代理发出
CONNECT
。 这会导致长时间超时,或者如果幸运的话,会出现如下错误:This was issue1424152 on Python 错误跟踪器。 错误报告中附加了一些补丁,可以在 Python 2.x 和 Python 3.x 中修复此问题。 问题已修复。
I followed the advice of other answers to this question and gave SUDS a try. After using it "in anger" I must agree: SUDS is very nice! Highly recommended!
I did run into trouble calling HTTPS-based web services from behind a proxy. At the time of this writing, this affects all Python web-service clients that use
urllib2
, so I'll document the solution here.The
urllib2
module shipping with python 2.6.2 and below will not issue aCONNECT
to the proxy for HTTPS-over-HTTP-proxy sessions. This results in a long timeout, or if you are lucky, an error that looks like:This was issue1424152 on the Python bug tracker. There are patches attached to the bug report that will fix this in Python 2.x and Python 3.x. The issue is already fixed.
我在 SUDS 方面有很好的经验
https://fedorahosted.org/suds
使用他们的 TestSuite 作为文档。
I had good experience with SUDS
https://fedorahosted.org/suds
Used their TestSuite as documentation.
SUDS 是必经之路,这是毫无疑问的。
SUDS is the way to go, no question about it.
对于查看 SUDS 的人来说,仅供参考,在解决此问题之前,SUDS 不支持 WSDL 中的“选择”标签:
https://fedorahosted.org/suds/ticket/342
参见:
泡沫和选择标签
Just an FYI warning for people looking at SUDS, until this ticket is resolved, SUDS does not support the "choice" tag in WSDL:
https://fedorahosted.org/suds/ticket/342
see:
suds and choice tag
SUDS 易于使用,但不保证可重入。 如果您将 WSDL Client() 对象保留在线程应用程序中以获得更好的性能,则存在一些风险。 解决这个风险的方法是clone()方法,它会抛出不可恢复的Python 5508错误,该错误似乎会打印但实际上并没有抛出异常。 可能会令人困惑,但它确实有效。 它仍然是迄今为止最好的 Python SOAP 客户端。
SUDS is easy to use, but is not guaranteed to be re-entrant. If you're keeping the WSDL Client() object around in a threaded app for better performance, there's some risk involved. The solution to this risk, the clone() method, throws the unrecoverable Python 5508 bug, which seems to print but not really throw an exception. Can be confusing, but it works. It is still by far the best Python SOAP client.
我们发布了一个新库:PySimpleSOAP,它为简单而实用的客户端/服务器提供支持。 它的目标是:易用性和灵活性(不需要类、自动生成的代码或 xml)、WSDL 自省和生成、WS-I 标准合规性、兼容性(包括 Java AXIS、.NET 和 Jboss WS)。 它包含在 Web2Py 中以实现全栈解决方案(补充其他支持的协议,例如 XML_RPC、JSON、AMF-RPC 等)。
如果有人正在学习 SOAP 或者想研究它,我认为这是一个不错的开始选择。
We released a new library: PySimpleSOAP, that provides support for simple and functional client/server. It goals are: ease of use and flexibility (no classes, autogenerated code or xml is required), WSDL introspection and generation, WS-I standard compliance, compatibility (including Java AXIS, .NET and Jboss WS). It is included into Web2Py to enable full-stack solutions (complementing other supported protocols such as XML_RPC, JSON, AMF-RPC, etc.).
If someone is learning SOAP or want to investigate it, I think it is a good choice to start.
我相信soaplib 已弃用其SOAP 客户端(“发送者”),转而使用suds。 此时,soaplib 专注于成为与 Web 框架无关的 SOAP 服务器(“接收器”)。 目前,soaplib 正在积极开发中,通常在 Python SOAP 邮件列表中进行讨论:
http://mail .python.org/mailman/listinfo/soap
I believe soaplib has deprecated its SOAP client ('sender') in favor of suds. At this point soaplib is focused on being a web framework agnostic SOAP server ('receiver'). Currently soaplib is under active development and is usually discussed in the Python SOAP mailing list:
http://mail.python.org/mailman/listinfo/soap
在我的结论中,我们有这样的结论:
Soap 客户端:
仅使用 Suds-jurko (2016 年更新)suds 维护和更新得很好。
更新 06/2017: suds-jurko 库未更新,显然已被放弃,
我测试了 zeep 库,但对令牌有限制,现在只支持 UsernameToken,我报告了 bug 创建时间戳令牌,作者更新代码来修复它。
Zeep 启动良好并且具有良好的 文档 ,所以我最近迁移了我的代码从泡沫到泽普,效果都很好。
Soap 服务器端:我们有 TGWS、soaplib(pysimplesoap 未测试)恕我直言,使用和帮助 soaplib 必须是选择。最诚挚的问候,
In my conclusion we have this:
Soap client side:
use only Suds-jurko (updated 2016)suds is well maintained and updated.
UPDATE 06/2017: suds-jurko library is not updated and apparently abandoned,
I tested zeep library but got limitations around tokens, by now just support UsernameToken, i report a bug to create timestamp token and author update the code to fix it.
Zeep start good and has good documentation , so i recently migrated my code from suds to zeep and works fine.
Soap server side:We have TGWS, soaplib (pysimplesoap not tested) IMHO use and help soaplib must be the choice.Best regards,
正如我建议的此处我建议你自己动手。 实际上并没有那么困难,我怀疑这就是没有更好的 Python SOAP 库的原因。
As I suggested here I recommend you roll your own. It's actually not that difficult and I suspect that's the reason there aren't better Python SOAP libraries out there.
肥皂水很不错。 我尝试了 SOAPpy,但没有让它按照我需要的方式工作,而肥皂水几乎可以立即工作。
suds is pretty good. I tried SOAPpy but didn't get it to work in quite the way I needed whereas suds worked pretty much straight away.
这可以帮助吗: http://users.skynet.be/ pascalbotte/rcx-ws-doc/python.htm#SOAPPY
我通过搜索
wsdl
和python
找到了它,理性的是,你需要SOAP 服务器的 wsdl 描述,用于执行任何有用的客户端包装......Could this help: http://users.skynet.be/pascalbotte/rcx-ws-doc/python.htm#SOAPPY
I found it by searching for
wsdl
andpython
, with the rational being, that you would need a wsdl description of a SOAP server to do any useful client wrappers....我们使用了 Python Web Services 中的 SOAPpy,但似乎 ZSI(相同来源)正在取代它。
We'd used SOAPpy from Python Web Services, but it seems that ZSI (same source) is replacing it.
我在生产环境中使用 SOAPpy 和 Python 2.5.3。
我必须在 SOAPpy 中手动编辑几个文件(有关标头代码位于错误位置的信息),但除此之外它可以工作并且继续非常可靠地工作。
Im using SOAPpy with Python 2.5.3 in a production setting.
I had to manually edit a couple of files in SOAPpy (something about header code being in the wrong place) but other than that it worked and continues to do so very reliably.