From a40fea3a3bbef8aba0a43c0e3badf42dc28f7515 Mon Sep 17 00:00:00 2001 From: Felix Frank Date: Wed, 11 Sep 2024 13:01:36 +0200 Subject: [PATCH 1/2] Fix the create_message function for clients with no default service. Even though the Client.create_message function expects a service parameter, this service was not passed on to the SOAP implementation. The SOAP binding would invariably use the default service in the client object, and raise an exception if it was not found. Fix this by adding an optional service parameter to the SoapBinding.create method as well. Fixes #833 --- src/zeep/client.py | 2 +- src/zeep/wsdl/bindings/soap.py | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/zeep/client.py b/src/zeep/client.py index fac7ecd7..261d15d8 100644 --- a/src/zeep/client.py +++ b/src/zeep/client.py @@ -148,7 +148,7 @@ def create_message(self, service, operation_name, *args, **kwargs): """ envelope, http_headers = service._binding._create( - operation_name, args, kwargs, client=self + operation_name, args, kwargs, client=self, service=service ) return envelope diff --git a/src/zeep/wsdl/bindings/soap.py b/src/zeep/wsdl/bindings/soap.py index 3a5e5433..efb358b0 100644 --- a/src/zeep/wsdl/bindings/soap.py +++ b/src/zeep/wsdl/bindings/soap.py @@ -59,7 +59,7 @@ def create_message(self, operation, *args, **kwargs): envelope, http_headers = self._create(operation, args, kwargs) return envelope - def _create(self, operation, args, kwargs, client=None, options=None): + def _create(self, operation, args, kwargs, client=None, options=None, service=None): """Create the XML document to send to the server. Note that this generates the soap envelope without the wsse applied. @@ -78,8 +78,11 @@ def _create(self, operation, args, kwargs, client=None, options=None): # Apply ws-addressing if client: + if service is None: + service = client.service + if not options: - options = client.service._binding_options + options = service._binding_options if operation_obj.abstract.wsa_action: envelope, http_headers = wsa.WsAddressingPlugin().egress( From 492596be7b6a41ed2b376d2b307df2d9db665faf Mon Sep 17 00:00:00 2001 From: Felix Frank Date: Fri, 31 Oct 2025 15:44:20 +0100 Subject: [PATCH 2/2] Regression fix: Avoid spurious client.service lookup The fix for create_message functions would lead to a regression when performing regular SOAP calls. The client.service member is not supposed to be accessed in this case (options is not None). Slightly restructured the code so that client.service is accessed only when needed again. --- src/zeep/wsdl/bindings/soap.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/zeep/wsdl/bindings/soap.py b/src/zeep/wsdl/bindings/soap.py index efb358b0..f7d3dec7 100644 --- a/src/zeep/wsdl/bindings/soap.py +++ b/src/zeep/wsdl/bindings/soap.py @@ -78,10 +78,9 @@ def _create(self, operation, args, kwargs, client=None, options=None, service=No # Apply ws-addressing if client: - if service is None: - service = client.service - if not options: + if service is None: + service = client.service options = service._binding_options if operation_obj.abstract.wsa_action: