Zeep: Python SOAP client¶
A fast and modern Python SOAP client
- Highlights:
- Compatible with Python 3.7, 3.8, 3.9, 3.10, 3.11 and PyPy
- Build on top of lxml and requests
- Support for Soap 1.1, Soap 1.2 and HTTP bindings
- Support for WS-Addressing headers
- Support for WSSE (UserNameToken / x.509 signing)
- Support for asyncio via httpx
- Experimental support for XOP messages
A simple example:
from zeep import Client client = Client('http://www.webservicex.net/ConvertSpeed.asmx?WSDL') result = client.service.ConvertSpeed( 100, 'kilometersPerhour', 'milesPerhour') assert result == 62.137
Quick Introduction¶
Zeep inspects the WSDL document and generates the corresponding code to use the services and types in the document. This provides an easy to use programmatic interface to a SOAP server.
The emphasis is on SOAP 1.1 and SOAP 1.2, however Zeep also offers support for HTTP Get and Post bindings.
Parsing the XML documents is done by using the lxml library. This is the most performant and compliant Python XML library currently available. This results in major speed benefits when processing large SOAP responses.
The SOAP specifications are unfortunately really vague and leave a lot of things open for interpretation. Due to this there are a lot of WSDL documents available which are invalid or SOAP servers which contain bugs. Zeep tries to be as compatible as possible but there might be cases where you run into problems. Don’t hesitate to submit an issue in this case (but please first read Reporting bugs).
Installation¶
Zeep is a pure-python module. This means that there is no C code which needs to be compiled. However the lxml dependency does contain C code since it uses libxml2 and libxslt. For linux/bsd this means you need to install libxml2-dev and libxslt-dev packages. For Windows this is unfortunately a bit more complicated. The easiest way is to install lxml via wheel files since that contains already compiled code for your platform.
To install wheel files you need a recent pip client. See https://pip.pypa.io/en/stable/installing/ how to install pip on your platform.
If you have installed pip then run:
pip install zeep
Note that the latest version to support Python 2.7, 3.3, 3.4 and 3.5 is Zeep 3.4, install via pip install zeep==2.4.0
This assumes that there are wheel files available for the latest lxml release. If that is not the case (https://pypi.python.org/pypi/lxml/) then first install lxml 4.2.5 since that release should have the wheel files for all platforms:
pip install lxml==4.2.5 zeep
When you want to use wsse.Signature() you will need to install the python
xmlsec module. This can be done by installing the xmlsec extras:
pip install zeep[xmlsec]
For the asyncio support in Python 3.6+ the httpx module is required, this
can be installed with the async extras:
pip install zeep[async]
Getting started¶
The first thing you generally want to do is inspect the wsdl file you need to implement. This can be done with:
python -mzeep <wsdl>
See python -mzeep --help for more information about this command.
Note
Zeep follows semver for versioning, however bugs can always occur.
So as always pin the version of zeep you tested with
(e.g. zeep==4.1.0’).
A simple use-case¶
To give you an idea how zeep works a basic example.
import zeep wsdl = 'http://www.soapclient.com/xml/soapresponder.wsdl' client = zeep.Client(wsdl=wsdl) print(client.service.Method1('Zeep', 'is cool'))
The WSDL used above only defines one simple function (Method1) which is
made available by zeep via client.service.Method1. It takes two arguments
and returns a string. To get an overview of the services available on the
endpoint you can run the following command in your terminal.
python -mzeep http://www.soapclient.com/xml/soapresponder.wsdl
Note
Note that unlike suds, zeep doesn’t enable caching of the wsdl documents by default. This means that everytime you initialize the client requests are done to retrieve the wsdl contents.
User guide¶
API Documentation¶
Changelog¶
- Changelog
- 4.2.0 (2022-111-03)
- 4.1.0 (2021年08月15日)
- 4.0.0 (2020年10月12日)
- 3.4.0 (2019年06月05日)
- 3.3.1 (2019年03月10日)
- 3.3.0 (2019年03月08日)
- 3.2.0 (2018年12月17日)
- 3.1.0 (2018年07月28日)
- 3.0.0 (2018年06月16日)
- 2.5.0 (2018年01月06日)
- 2.4.0 (2017年08月26日)
- 2.3.0 (2017年08月06日)
- 2.2.0 (2017年06月19日)
- 2.1.1 (2017年06月11日)
- 2.1.0 (2017年06月11日)
- 2.0.0 (2017年05月22日)
- 1.6.0 (2017年04月27日)
- 1.5.0 (2017年04月22日)
- 1.4.1 (2017年04月01日)
- 1.4.0 (2017年04月01日)
- 1.3.0 (2017年03月14日)
- 1.2.0 (2017年03月12日)
- 1.1.0 (2017年02月18日)
- 1.0.0 (2017年01月31日)
- 0.27.0 (2017年01月28日)
- 0.26.0 (2017年01月26日)
- 0.25.0 (2017年01月23日)
- 0.24.0 (2016年12月16日)
- 0.23.0 (2016年11月24日)
- 0.22.1 (2016年11月22日)
- 0.22.0 (2016年11月13日)
- 0.21.0 (2016年11月02日)
- 0.20.0 (2016年10月24日)
- 0.19.0 (2016年10月18日)
- 0.18.1 (2016年09月23日)
- 0.18.0 (2016年09月23日)
- 0.17.0 (2016年09月12日)
- 0.16.0 (2016年09月06日)
- 0.15.0 (2016年09月04日)
- 0.14.0 (2016年08月03日)
- 0.13.0 (2016年07月17日)
- 0.12.0 (2016年07月09日)
- 0.11.0 (2016年07月03日)
- 0.10.0 (2016年06月22日)
- 0.9.1 (2016年06月17日)
- 0.9.0 (2016年06月14日)
- 0.8.1 (2016年06月08日)
- 0.8.0 (2016年06月07日)
- 0.7.1 (2016年06月01日)
- 0.7.0 (2016年05月31日)
- 0.6.0 (2016年05月21日)
- 0.5.0 (2015年05月08日)
- 0.4.0 (2016年04月17日)
- 0.3.0 (2016年04月10日)
- 0.2.5 (2016年04月05日)
- 0.2.4 (2016年04月03日)
- 0.2.3 (2016年04月03日)
- 0.2.2 (2016年04月03日)
- 0.2.1 (2016年04月03日)
- 0.2.0 (2016年04月03日)
- 0.1.1 (2016年03月20日)
- 0.1.0 (2016年03月20日)