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 = 'https://redservipruebas.almalogix.com/distribucion/webservices/ws_cotizadorEnvios.php?wsdl' client = zeep.Client(wsdl=wsdl,plugins=[MyLoggingPlugin()]) client.set_ns_prefix('ws', '/distribucion/webservices/ws_cotizadorEnvios.php') client.set_ns_prefix('xsi',"http://www.w3.org/2001/XMLSchema-instance") client.set_ns_prefix('soapenv',"http://schemas.xmlsoap.org/soap/envelope/") client.set_ns_prefix('soapenc','http://schemas.xmlsoap.org/soap/encoding/') factory = client.type_factory('ws')
By using the
python -mzeep https://redservipruebas.almalogix.com/distribucion/webservices/ws_cotizadorEnvios.php?wsdl command I discovered that the service is called
My problem is that by having this name I am not able to make the call to the service using
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.