Zeep - Python SOAP Client
Zeep is a fast and modern Python SOAP client library, currently at version 4.3.2. It simplifies interactions with SOAP web services by inspecting WSDL documents and generating a Pythonic interface. The library is considered stable, focusing on bug fixes, with major releases occurring less frequently, typically when significant changes to Python support or underlying dependencies are required.
Warnings
- breaking Zeep v4.3.0 dropped official support for Python 3.7 and 3.8. Version 4.2.0 dropped support for Python 3.6. Ensure your Python environment meets the `requires_python>=3.8` requirement.
- breaking Starting with Zeep v4.3.0, the project fully migrated to `pyproject.toml`, removing `setup.py`. This impacts build systems that might rely on the presence of `setup.py`.
- gotcha A regression in parsing `xsd:Date` with negative timezones was introduced and fixed in version 4.3.1. This issue could occur when using `isodate==0.7.2` with `zeep` versions prior to 4.3.1, leading to incorrect date interpretations or exceptions.
- gotcha When using `httpx` for asynchronous transport, passing `data` for POST requests might trigger `DeprecationWarning` in older `httpx` versions. Zeep v4.2.0 includes a fix for this.
- gotcha Disabling TLS/SSL verification (e.g., `session.verify = False` for synchronous `requests`-based transport, or similar for `httpx`) is generally discouraged in production environments due to security risks. Zeep will pass these settings to the underlying transport.
- gotcha Zeep operates in a 'strict' mode by default, which rigorously checks WSDL and XML against standards. While robust, some non-compliant SOAP servers might require disabling strict mode (`zeep.Settings(strict=False)`), which could potentially lead to data-loss or unexpected behavior.
- breaking For `AsyncTransport` (used with `AsyncClient`), the `session` argument that previously accepted a `requests.Session` object is deprecated. It now expects an `httpx.AsyncClient` object to be passed via the `client` argument.
Install
-
pip install zeep
Imports
- Client
from zeep import Client
- AsyncClient
from zeep import AsyncClient
- Settings
from zeep import Settings
- Transport
from zeep.transports import Transport
- AsyncTransport
from zeep.transports import AsyncTransport
Quickstart
import os
from zeep import Client
# A public WSDL for demonstration purposes
wsdl_url = os.environ.get('ZEEP_WSDL_URL', 'http://www.webservicex.net/ConvertSpeed.asmx?WSDL')
try:
client = Client(wsdl_url)
# Inspect available services and operations
print(f"Service operations: {list(client.service._operations.keys())}")
# Call a service operation
result = client.service.ConvertSpeed(100, 'kilometersPerhour', 'milesPerhour')
print(f"100 km/h in mph: {result}")
except Exception as e:
print(f"An error occurred: {e}")
print("Please ensure the WSDL URL is accessible and valid.")
print("You can try setting the ZEEP_WSDL_URL environment variable.")