mvantellingen / python-zeep

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

zeep-generator? tool for generating Python code based on a WSDL document? #1372

Open AlexandreHGuerra opened 1 year ago

AlexandreHGuerra commented 1 year ago

Hello, thanks for the help Is there any code generator at all for zeep? i was doing a check about zeep fetures querying chatgpt, and the following text below appeared. is it 'hallucinating'?

question ¨ zeep is quite capable, but i would like to look after a library that would allow me to compile a WSDL structure into a python module, in order to help me avoid excessive code manipulation for data structures "

answer In that case, you might want to consider using python-zeep in combination with zeep-generator. python-zeep is a modern, fast and well-documented SOAP client for Python that allows you to easily consume SOAP web services. It also includes support for generating Python code from a WSDL document.

zeep-generator is a companion tool to python-zeep that can generate Python code based on a WSDL document. It generates a module that defines all the types and services specified in the WSDL, so you don't have to manually create data structures for each request and response.

Here's an example of how to use zeep-generator to generate Python code from a WSDL document:

Install zeep-generator using pip:

Copy code pip install zeep-generator Generate Python code from the WSDL document using zeep-generator:

arduino Copy code zeep-generate http://example.com/soap.wsdl -o mysoapmodule This will generate a Python module named mysoapmodule in the current directory, containing all the types and services specified in the WSDL document.

Import the generated module and use it to interact with the SOAP service:

java Copy code from mysoapmodule import MyService

client = MyService()

result = client.some_method(some_param='some_value') This will create a client object for the SOAP service and call the some_method method with the specified parameter. The response will be returned as a Python object, without you having to manually construct the data structures.

Using zeep-generator can save you a lot of time and effort, since you don't have to manually create data structures for each request and response. Instead, you can focus on using the generated code to interact with the SOAP service.