Zeep: Python SOAP client¶
A fast and modern Python SOAP client
- Modern codebase compatible with Python 2.7, 3.3, 3.4, 3.5 and PyPy
- Build on top of lxml and requests
- Supports recursive WSDL and XSD documents.
- Supports the xsd:choice and xsd:any elements.
- Uses the defusedxml module for handling potential XML security issues
- Support for WSSE (UsernameToken only for now)
- Experimental support for HTTP bindings
- Experimental support for WS-Addressing headers
- Features still in development include:
- WSSE x.509 support (BinarySecurityToken)
- WS Policy support
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
Zeep inspects the wsdl document and generates the corresponding bindings. 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 experimental 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 retrieving 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 (please see Reporting bugs).
You can install the latest version of zeep using pip:
pip install zeep
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>
python -mzeep --help for more information about this command.
Since this module hasn’t reached 1.0.0 yet their might be minor
releases which introduce backwards compatible changes. While I try
to keep this to a minimum it can still happen. So as always pin the
version of zeep you used (e.g.
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
- Using Zeep
- Transport options
- WS-Addressing (WSA)
- WS-Security (WSSE)
- Reporting bugs
- 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)