Skip to content

Commit

Permalink
Fix the create_message function for clients with no default service.
Browse files Browse the repository at this point in the history
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 mvantellingen#833
  • Loading branch information
Felix Frank committed Sep 11, 2024
1 parent 377d931 commit a40fea3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/zeep/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 5 additions & 2 deletions src/zeep/wsdl/bindings/soap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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(
Expand Down

0 comments on commit a40fea3

Please sign in to comment.