Quick Overview
Zeep is a Python SOAP client library that provides a modern and user-friendly interface for working with SOAP web services. It offers automatic XML parsing, type conversion, and supports complex WSDL structures, making it easier to interact with SOAP APIs in Python applications.
Pros
- Easy to use with a simple and intuitive API
- Supports complex WSDL structures and XML schemas
- Automatic type conversion between Python and XML
- Extensible with custom data types and transport methods
Cons
- Performance can be slower compared to lower-level XML libraries
- Limited support for older SOAP versions and non-standard implementations
- Documentation could be more comprehensive for advanced use cases
- Debugging complex SOAP issues can be challenging
Code Examples
- Creating a SOAP client and making a simple request:
from zeep import Client
client = Client('http://www.webservicex.net/ConvertSpeed.asmx?WSDL')
result = client.service.ConvertSpeed(
speed=100,
fromUnit='kilometersPerHour',
toUnit='milesPerHour'
)
print(f"100 km/h is equal to {result} mph")
- Using a custom transport with authentication:
from zeep import Client
from zeep.transports import Transport
from requests import Session
session = Session()
session.auth = ('username', 'password')
transport = Transport(session=session)
client = Client('http://example.com/service?WSDL', transport=transport)
result = client.service.SomeOperation(param1='value1', param2='value2')
- Working with complex types:
from zeep import Client
client = Client('http://example.com/complex_service?WSDL')
# Create a complex type instance
address_type = client.get_type('ns0:AddressType')
address = address_type(
street='123 Main St',
city='Anytown',
state='CA',
zip='12345'
)
# Use the complex type in a service call
result = client.service.CreateCustomer(name='John Doe', address=address)
Getting Started
To get started with Zeep, follow these steps:
-
Install Zeep using pip:
pip install zeep
-
Import the Client class and create a client instance:
from zeep import Client client = Client('http://example.com/service?WSDL')
-
Call a service method:
result = client.service.SomeMethod(param1='value1', param2='value2') print(result)
For more advanced usage and configuration options, refer to the official Zeep documentation.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Zeep: Python SOAP client
A Python SOAP client
Highlights:
- Compatible with Python 3.9, 3.10, 3.11, 3.12, 3.13 and PyPy3
- Built on top of lxml, requests, and httpx
- 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 using the httpx module
- Experimental support for XOP messages
Please see the documentation for more information.
Status
[!NOTE] I consider this library to be stable. Since no new developments happen around the SOAP specification, it won't be updated that much. Good PRs which fix bugs are always welcome, however.
Installation
pip install zeep
Zeep uses the lxml library for parsing XML. See lxml installation requirements.
Usage
from zeep import Client
client = Client('tests/wsdl_files/example.rst')
client.service.ping()
To quickly inspect a WSDL file, use:
python -m zeep <url-to-wsdl>
Please see the documentation for more information.
Sponsors
Support
If you want to report a bug, please first read the bug reporting guidelines.
Please only report bugs, not support requests, to the GitHub issue tracker.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot