Developed an APIRest with FastAPI and Python 11. I am using the library zeep
to sign a request to consume a SOAP API and in my local environment it works correctly. When the application runs on a Docker container it fails on the line where the request is made. Simply stop the container, don’t show any error log.
Below is the code snippet
from fastapi import FastAPIfrom requests import Session as RequestSessionfrom zeep import Clientfrom zeep.wsse.username import UsernameTokenfrom zeep.wsse.signature import Signaturefrom zeep.transports import Transportapp = FastAPI()@app.get("/")def read_root(): request = {'SolicitudDatosLocalizacion':{'TipoIdentificacion': '1','Identificacion': 'xxxxxxxxx','PrimerApellido': 'XXXXXXXX','Usuario': 'xxxxxxxxxx','Clave': 'xxxxx', } } session = RequestSession() session.cert = "service_public_key.pem" transport_certificate = Transport(session=session) signature_config = Signature(key_file="service_private_key.key", certfile="c55.crt") user_name_token = UsernameToken('x-xxxxxxx.x', 'xxx-xx--xx') client = Client('https://demo-servicesesb.datacredito.com.co:443/wss/localizacion/services/ServicioLocalizacion?wsdl', wsse = CustomSignature([user_name_token, signature_config]), transport = transport_certificate ) service = client.bind('ServicioLocalizacion', 'ServicioLocalizacionPort.dmz.https') response = service.consultarDatosLocalizacion(request)#Error print(response) return {"Hello": "World"}
Initially I thought it was an error associated with some dependency of xmlsec
(used for wsse.Signature()
) but not, it is when the request is made. Please your help !