Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create service for AsyncClient as AsyncServiceProxy #1413

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions src/zeep/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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

Expand Down