python-zeep icon indicating copy to clipboard operation
python-zeep copied to clipboard

urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7fb685c865b0>: Failed to establish a new connection: [Errno -2] Name or service not known

Open StraigenDaigen opened this issue 4 years ago • 0 comments

Hi! I want to replicate a request from SOAP UI in zeep.

<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:inf="http://infocomercial.cifin.asobancaria.com"> <soapenv:Header/> <soapenv:Body> <inf:consultaXml soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <in0 xsi:type="dto:ParametrosConsultaDTO" xmlns:dto="http://dto.infocomercial.cifin.asobancaria.com"> <codigoInformacion xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">1401</codigoInformacion> <motivoConsulta xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">24</motivoConsulta> <numeroIdentificacion xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">80775779</numeroIdentificacion> <tipoIdentificacion xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">1</tipoIdentificacion> </in0> </inf:consultaXml> </soapenv:Body> </soapenv:Envelope>

My python code is following:

` import requests from requests import Session from requests.auth import HTTPBasicAuth # or HTTPDigestAuth, or OAuth1, etc. from zeep import Client from zeep.transports import Transport from zeep import xsd

session = Session() session.cert = "XXXXXX/certificate.pem" session.auth = HTTPBasicAuth("XXXXXX", "XXXX")

end_point= 'https://cifinpruebas.asobancaria.com/InformacionComercialWS/services/InformacionComercial?wsdl' soap_client = Client(end_point, transport=Transport(session=session), service_name="InformacionComercialWSService", port_name="InformacionComercial")

factory = soap_client.type_factory('ns0') request = factory.ParametrosConsultaDTO(codigoInformacion="1401", motivoConsulta="24", numeroIdentificacion="80775779", tipoIdentificacion="1")

print(request) try: print(soap_client.service.consultaXml(request)) except requests.exceptions.ConnectionError as e: response = "Without response" print(response) `

But it shows me an error, I think the system is not validating the certificate (.pem), When I'm using SOAP UI I don't have problems.

the error is:urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7fb685c865b0>: Failed to establish a new connection: [Errno -2] Name or service not known

Any suggestion? https://stackoverflow.com/questions/68489667/how-to-establish-connection-with-soap-webservice-using-python-zeep-library

StraigenDaigen avatar Jul 27 '21 17:07 StraigenDaigen