Skip to content

Commit b53b177

Browse files
michaelheyvaertmvantellingen
authored andcommitted
allow to pass a preparsed Document in the zeep Client
1 parent e8fb1e2 commit b53b177

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

src/zeep/client.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def __getitem__(self, key):
3838
class Client:
3939
"""The zeep Client.
4040
41-
:param wsdl:
41+
:param wsdl: Url/local WSDL location or preparsed WSDL Document
4242
:param wsse:
4343
:param transport: Custom transport class.
4444
:param service_name: The service name for the service binding. Defaults to
@@ -70,7 +70,10 @@ def __init__(
7070
self.transport = (
7171
transport if transport is not None else self._default_transport()
7272
)
73-
self.wsdl = Document(wsdl, self.transport, settings=self.settings)
73+
if isinstance(wsdl, Document):
74+
self.wsdl = wsdl
75+
else:
76+
self.wsdl = Document(wsdl, self.transport, settings=self.settings)
7477
self.wsse = wsse
7578
self.plugins = plugins if plugins is not None else []
7679

tests/test_client.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
from tests.utils import load_xml
77
from zeep import client, xsd
8+
from zeep.wsdl import Document
9+
from zeep.transports import Transport
810
from zeep.exceptions import Error
911

1012

@@ -14,6 +16,13 @@ def test_bind():
1416
assert service
1517

1618

19+
def test_bind_existing_document():
20+
wsdl = Document("tests/wsdl_files/soap.wsdl", transport=Transport())
21+
client_obj = client.Client(wsdl)
22+
service = client_obj.bind()
23+
assert service
24+
25+
1726
def test_unknown_transport():
1827
client_obj = client.Client("tests/wsdl_files/soap_transport_err.wsdl")
1928
service = client_obj.bind()

0 commit comments

Comments
 (0)