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

Add create_service to AsyncClient #1202

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion src/zeep/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from zeep.client import AsyncClient, CachingClient, Client
from zeep.plugins import Plugin
from zeep.settings import Settings
from zeep.transports import Transport
from zeep.transports import AsyncTransport, Transport
from zeep.xsd.valueobjects import AnyObject

__version__ = "4.1.0"
__all__ = [
"AsyncClient",
"AsyncTransport",
"CachingClient",
"Client",
"Plugin",
Expand Down
16 changes: 16 additions & 0 deletions src/zeep/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,22 @@ def bind(
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