How to call a zeep python service?


I'm trying to connect to a SOAP service with the Zeep library.

I have a function that mocks the data and makes the call:

def cotizacionGuia(self,valor_declarado):
    wsdl = ''
    client = zeep.Client(wsdl=wsdl,plugins=[MyLoggingPlugin()])
    client.set_ns_prefix('ws', '/distribucion/webservices/ws_cotizadorEnvios.php')
    factory = client.type_factory('ws')

By using the python -mzeep command I discovered that the service is called WebServiceCotizadorEnvios.ws_cotizarEnvio .

My problem is that by having this name I am not able to make the call to the service using client.service.WebServiceCotizadorEnvios.ws_cotizarEnvio() .

Is there a way to rename the name of the service?

I discovered that writing client.service._binding.port_type.operations I get a dict where the name of the service is found as a key and the object as a value, so I thought that if I can modify the key, I could make the call.

I have managed to solve the problem by making the following change:

There are two ways to call the functions of service , one of them is the one I've been using so far client.service.llamada() and the other one is client.service['llamada'](parametros) . In this second way it does not matter what name the function has that we can make the call.

asked by F Delgado 28.03.2018 в 12:26

0 answers