Skip to content

Commit

Permalink
allow to pass a preparsed Document in the zeep Client
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelheyvaert authored and mvantellingen committed Nov 3, 2022
1 parent e8fb1e2 commit b53b177
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/zeep/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 []

Expand Down
9 changes: 9 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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()
Expand Down

0 comments on commit b53b177

Please sign in to comment.