From f767f1d95d053663bf1fcb6301330c66b4562c26 Mon Sep 17 00:00:00 2001 From: rastruja Date: Wed, 10 Apr 2024 09:21:36 +0200 Subject: [PATCH] Create service for AsyncClient as AsyncServiceProxy AsyncClient inherits of Client, Client create_service returns ServiceProxy, AsyncClient need AsyncServiceProxy --- src/zeep/client.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/zeep/client.py b/src/zeep/client.py index fac7ecd7..4018cdf2 100644 --- a/src/zeep/client.py +++ b/src/zeep/client.py @@ -230,9 +230,9 @@ def bind( service_name: typing.Optional[str] = None, port_name: typing.Optional[str] = None, ): - """Create a new ServiceProxy for the given service_name and port_name. + """Create a new AsyncServiceProxy for the given service_name and port_name. - The default ServiceProxy instance (`self.service`) always referes to + The default AsyncServiceProxy instance (`self.service`) always referes to the first service/port in the wsdl Document. Use this when a specific port is required. @@ -243,7 +243,23 @@ def bind( service = self._get_service(service_name) port = self._get_port(service, port_name) return AsyncServiceProxy(self, port.binding, **port.binding_options) + + def create_service(self, binding_name, address): + """Create a new AsyncServiceProxy for the given binding name and address. + :param binding_name: The QName of the binding + :param address: The address of the endpoint + + """ + try: + binding = self.wsdl.bindings[binding_name] + except KeyError: + raise ValueError( + "No binding found with the given QName. Available bindings " + "are: %s" % (", ".join(self.wsdl.bindings.keys())) + ) + return AsyncServiceProxy(self, binding, address=address) + async def __aenter__(self): return self