diff --git a/src/zeep/client.py b/src/zeep/client.py index 6c42741f..56f9a61c 100644 --- a/src/zeep/client.py +++ b/src/zeep/client.py @@ -38,7 +38,7 @@ def __getitem__(self, key): class Client: """The zeep Client. - :param wsdl: + :param wsdl: Url/local WSDL location or preparsed WSDL Document :param wsse: :param transport: Custom transport class. :param service_name: The service name for the service binding. Defaults to @@ -70,7 +70,10 @@ def __init__( self.transport = ( transport if transport is not None else self._default_transport() ) - self.wsdl = Document(wsdl, self.transport, settings=self.settings) + if isinstance(wsdl, Document): + self.wsdl = wsdl + else: + self.wsdl = Document(wsdl, self.transport, settings=self.settings) self.wsse = wsse self.plugins = plugins if plugins is not None else [] diff --git a/tests/test_client.py b/tests/test_client.py index c73170fc..3b26578b 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -5,6 +5,8 @@ from tests.utils import load_xml from zeep import client, xsd +from zeep.wsdl import Document +from zeep.transports import Transport from zeep.exceptions import Error @@ -14,6 +16,13 @@ def test_bind(): assert service +def test_bind_existing_document(): + wsdl = Document("tests/wsdl_files/soap.wsdl", transport=Transport()) + client_obj = client.Client(wsdl) + service = client_obj.bind() + assert service + + def test_unknown_transport(): client_obj = client.Client("tests/wsdl_files/soap_transport_err.wsdl") service = client_obj.bind()