pythonxmlsoapzeep

How to define a "base url" for resources when creating a zeep client?


I'm trying to parse a WSDL file using zeep.

import zeep

zeep.Client('https://sede.agenciatributaria.gob.es/static_files/Sede/Procedimiento_ayuda/G417/FicherosSuministros/V_1_1/WSDL/SuministroFactEmitidas.wsdl')

This failes with the following error:

requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://sede.agenciatributaria.gob.es/static_files/Sede/Procedimiento_ayuda/G417/FicherosSuministros/V_1_1/WSDL/SuministroInformacion.xsd

From what I understand, since the wsdl file points to SuministroInformacion.xsd using a relative path, zeep assumes both files are in the same directory. But in this case, all the resources are located in another directory.

Can I specify a base url for the resources? If not, is there a way around this ? Thank you!


Solution

  • That service WSDL is broken.

    The schemaLocation indicates the same folder as the WSDL document, but the XSDs are actually located at the address of the namespace.

    Zeep does the correct thing, but it won't work with a broken WSDL.

    If you have access to the provider of that service, tell them to fix it.

    If they won't fix it, then download the WSDL, download all the XSD files that the WSDL is trying to import, place all files in one folder, then tell zeep to use the local WSDL with:

    zeep.Client('C:\\Download_Folder_Or_Whatever\\SuministroFactEmitidas.wsdl')
    

    This is a workaround that could work. The proper fix is for the service provider to repair their WSDL.