mvantellingen / python-zeep

A Python SOAP client
http://docs.python-zeep.org
Other
1.87k stars 579 forks source link

Offline WSDL to production server #982

Open rb-john opened 5 years ago

rb-john commented 5 years ago

Is it possible to configure Zeep to read an offline (from file) WSDL and then access online service URI.

Use case being some production SOAP do not services do not publish WSDL. But internal we have access to the WSDL file.

prietopa commented 4 years ago

Yes it is!! In my project I configure a data folder, contains all WSDL and XSD files. In settings.py y add this folder to add to distribution. In python 2.X you must use manifest file. I have a setup.py to read the wsdl file from 'data' folder:

import os.path

# url wsdl in data folder
my_path = os.path.abspath(os.path.dirname(__file__))
CUSTOMSERVICE_WSDL = os.path.join(my_path, "data/CustomService.wsdl")

# BINDING
CUSTOMSERVICE_BINDING_NAME = "{http://www.entreprise.com}CustomService.Soap12Binding"

Use this constants to create client:

transport = ...
client = GClient(
            CUSTOMSERVICE_WSDL,
            transport=transport,
            plugins=[]
        )
service_proxy = client.create_service(CUSTOMSERVICE_BINDING_NAME, url)