A comprehensive Python SOAP client library for consuming SOAP web services with support for SOAP 1.1/1.2, WSSE authentication, and async operations
npx @tessl/cli install tessl/pypi-zeep@4.3.0A comprehensive Python SOAP client library for consuming SOAP web services with support for SOAP 1.1/1.2, WSSE authentication, and async operations. Zeep provides a modern, Pythonic interface for working with SOAP services, automatic WSDL parsing, type conversion, fault handling, and comprehensive error reporting.
pip install zeeppip install zeep[async] for async supportpip install zeep[xmlsec] for XML securityimport zeep
from zeep import Client, AsyncClient, Settings, TransportFor advanced features:
from zeep import Plugin, CachingClient
from zeep.wsse import UsernameToken, Signature
from zeep.xsd import AnyObject
from zeep.cache import InMemoryCache, SqliteCache
from zeep.helpers import serialize_objectfrom zeep import Client
# Create a SOAP client
client = Client('http://example.com/service.wsdl')
# Call a SOAP operation
result = client.service.SomeOperation(param1='value1', param2='value2')
# Work with the result
print(result)
# Access different services/ports if needed
specific_service = client.bind('ServiceName', 'PortName')
result = specific_service.SomeOperation(param='value')Zeep is built around several core components:
The library automatically handles WSDL parsing, namespace management, type conversion between Python objects and XML, and provides comprehensive error reporting for debugging SOAP interactions.
Core SOAP client functionality for connecting to web services, calling operations, and handling responses. Includes both synchronous and asynchronous clients with automatic WSDL parsing and type conversion.
class Client:
def __init__(
self,
wsdl: str,
wsse=None,
transport=None,
service_name=None,
port_name=None,
plugins=None,
settings=None
): ...
def bind(self, service_name: str = None, port_name: str = None): ...
def create_service(self, binding_name: str, address: str): ...
def create_message(self, service, operation_name: str, *args, **kwargs): ...
def type_factory(self, namespace: str): ...
def get_type(self, name: str): ...
def get_element(self, name: str): ...
def set_ns_prefix(self, prefix: str, namespace: str): ...
def set_default_soapheaders(self, headers): ...
class AsyncClient(Client): ...
class CachingClient(Client): ...HTTP transport configuration, caching, session management, and XML parsing settings. Controls how zeep communicates with SOAP services and processes XML documents.
class Transport:
def __init__(
self,
cache=None,
timeout: int = 300,
operation_timeout: int = None,
session=None
): ...
class Settings:
def __init__(
self,
strict: bool = True,
raw_response: bool = False,
force_https: bool = True,
extra_http_headers=None,
xml_huge_tree: bool = False,
forbid_dtd: bool = False,
forbid_entities: bool = True,
forbid_external: bool = True,
xsd_ignore_sequence_order: bool = False
): ...Web Services Security features including username tokens, digital signatures, and authentication mechanisms for secure SOAP communication.
class UsernameToken:
def __init__(self, username: str, password: str, password_digest: bool = False): ...
class Signature:
def __init__(self, key_file: str, cert_file: str): ...
class BinarySignature(Signature): ...
class MemorySignature(Signature): ...
class Compose: ...XML Schema processing, type conversion, and handling of complex XML structures. Provides tools for working with XSD types and converting between Python objects and XML.
class AnyObject:
def __init__(self, xsd_object, value): ...
# XSD processing utilities and type conversion
class Schema: ...
# XSD constants
Nil: object
SkipValue: object
# Helper functions
def serialize_object(obj): ...Extensible plugin architecture for intercepting and modifying SOAP requests and responses. Enables custom logging, authentication, caching, and other cross-cutting concerns.
class Plugin:
def ingress(self, envelope, http_headers, operation): ...
def egress(self, envelope, http_headers, operation, binding_options): ...
class HistoryPlugin(Plugin):
def __init__(self, maxlen: int = 1): ...Comprehensive exception hierarchy for handling SOAP faults, transport errors, XML parsing issues, and validation failures with detailed error information.
class Error(Exception): ...
class Fault(Error): ...
class TransportError(Error): ...
class ValidationError(Error): ...
class XMLSyntaxError(Error): ...
class WsdlSyntaxError(Error): ...# Main client types
Client = typing.Type[Client]
AsyncClient = typing.Type[AsyncClient]
CachingClient = typing.Type[CachingClient]
# Configuration types
Settings = typing.Type[Settings]
Transport = typing.Type[Transport]
AsyncTransport = typing.Type[AsyncTransport]
# Security types
UsernameToken = typing.Type[UsernameToken]
Signature = typing.Type[Signature]
# XSD types
AnyObject = typing.Type[AnyObject]
Schema = typing.Type[Schema]
# Plugin types
Plugin = typing.Type[Plugin]
HistoryPlugin = typing.Type[HistoryPlugin]
# Cache types
InMemoryCache = typing.Type[InMemoryCache]
SqliteCache = typing.Type[SqliteCache]
# Helper functions
def serialize_object(obj): ...