我以前从未使用过SOAP,对Python也有点陌生。我这样做是为了让自己熟悉这两种技术。我已经安装了soapplib,并试图阅读他们的客户端文档,但我不太理解它。是否还有其他更适合作为Python的SOAP客户端库的东西?

编辑:为了以防万一,我使用的是Python 2.6。


当前回答

更新(2016):

如果您只需要SOAP客户机,有一个维护良好的库叫做zeep。它同时支持Python 2和Python 3:)


更新:

除了上面提到的,我还会提到Python WebServices页面,它总是最新的,包括所有主动维护的模块和推荐的SOAP和所有其他webservice类型的模块。


不幸的是,目前我不认为有一个“最好的”Python SOAP库。每一种主流方法都有其优缺点。

老库:

是“最好的”,但不再保持。在Python 2.5+上不工作 ZSI:使用起来非常痛苦,开发也很慢。有一个名为“SOAPpy”的模块,它与上面的SOAPy不同。

“新”库:

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. SOAPpy: Distinct from the abandoned SOAPpy that's hosted at the ZSI link above, this version was actually maintained until 2011, now it seems to be abandoned too. soaplib: Easy to use python library for writing and calling soap web services. Webservices written with soaplib are simple, lightweight, work well with other SOAP implementations, and can be deployed as WSGI applications. osa: A fast/slim easy to use SOAP python client library.

以上,我个人只使用过SUDS,而且我非常喜欢它。

其他回答

更新(2016):

如果您只需要SOAP客户机,有一个维护良好的库叫做zeep。它同时支持Python 2和Python 3:)


更新:

除了上面提到的,我还会提到Python WebServices页面,它总是最新的,包括所有主动维护的模块和推荐的SOAP和所有其他webservice类型的模块。


不幸的是,目前我不认为有一个“最好的”Python SOAP库。每一种主流方法都有其优缺点。

老库:

是“最好的”,但不再保持。在Python 2.5+上不工作 ZSI:使用起来非常痛苦,开发也很慢。有一个名为“SOAPpy”的模块,它与上面的SOAPy不同。

“新”库:

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. SOAPpy: Distinct from the abandoned SOAPpy that's hosted at the ZSI link above, this version was actually maintained until 2011, now it seems to be abandoned too. soaplib: Easy to use python library for writing and calling soap web services. Webservices written with soaplib are simple, lightweight, work well with other SOAP implementations, and can be deployed as WSGI applications. osa: A fast/slim easy to use SOAP python client library.

以上,我个人只使用过SUDS,而且我非常喜欢它。

我听从了其他回答这个问题的建议,尝试了一下SUDS。在“愤怒地”使用它之后,我必须同意:SUDS非常好!强烈推荐!

我确实遇到了从代理后面调用基于http的web服务的麻烦。在撰写本文时,这将影响所有使用urllib2的Python web服务客户机,因此我将在这里记录解决方案。

python 2.6.2及以下版本附带的urllib2模块不会为http -over- http -代理会话向代理发出CONNECT。这会导致很长时间的超时,或者如果你幸运的话,会出现如下错误:

abort: error: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol

这是Python错误跟踪器的第1424152号问题。在Python 2中,bug报告附带的补丁将修复这个问题。3.x和Python 3.x。这个问题已经解决了。

我使用SOAPpy与Python 2.5.3在生产设置。

我不得不手动编辑SOAPpy中的几个文件(关于头代码在错误的地方),但除此之外,它工作并继续这样做非常可靠。

SUDS易于使用,但不能保证可再入。如果您在线程应用程序中保留WSDL Client()对象以获得更好的性能,则会涉及一些风险。此风险的解决方案是clone()方法,它会抛出不可恢复的Python 5508错误,该错误似乎打印了异常,但并没有真正抛出异常。可能会让人困惑,但它很有效。它仍然是迄今为止最好的Python SOAP客户机。

肥皂水很不错。我尝试了SOAPpy,但没有得到它的工作方式,我需要而肥皂水工作得很直接。