regarding Authentification on DHL-SOAP API with zeep
i tried authenticating with the code provided by derAndre. but for me it didn't worked.
i am just trying to get the "getVersion" operation but it failed because of the Authentification.
But if i use it, i get an 401.
Server returned response (401) with invalid XML: Invalid XML content received (Space required after the Public Identifier, line 1, column 50). Content: b'\n\n401 Unauthorized\n\nUnauthorized
\nThis server could not verify that you\nare authorized to access the document\nrequested. Either you supplied the wrong\ncredentials (e.g., bad password), or your\nbrowser doesn\'t understand how to supply\nthe credentials required.
\n\n'
this is the code, and i'm not getting the hang of it.
session = Session()
session.auth = HTTPBasicAuth(settings.DHL_SOAP_API_USER,settings.DHL_SOAP_API_PW)
client = Client(settings.DHL_WSDL, transport=Transport(session=session))
# Build Authentification header for API-Endpoint using zeep xsd
header = xsd.Element(
'{http://test.python-zeep.org}Authentification',
xsd.ComplexType([
xsd.Element(
'{http://test.python-zeep.org}user',
xsd.String()),
xsd.Element(
'{http://test.python-zeep.org}signature',
xsd.String()),
])
)
header_value = header(user=settings.DHL_SOAP_API_USER, signature=settings.DHL_SOAP_API_PW)
result = client.service.getVersion('majorRelease:?', 'minorRelease:?', _soapheaders=[header_value])