Forum > Spanish
Consumir Web Service Seguro via HTTPS
FOV_2001:
Hola a todos,
Luego de semanas de escribir, probar y buscar, llego a un callejón sin salida y espero puedan ayudarme.
Desde hace mucho tengo una Librería desarrollada en Delphi funcionando correctamente, habiendo importado un WSDL, y consumiéndolo vía https.
Mi problema, surge en la migración a la misma librería en Lazarus, donde no consigo que el Web Service me responda, usando exactamente la misma configuración, la cual intentaré detallar
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function TDM_S2S.Registrar_Cliente(var Parametro: ClientRegisterRQ_Type): TS2S_Registrar_Cliente_Rec;var CCDataTest : ServicePortType; LResultado : ClientRegisterRS; begin With Mod_Auxiliar do if (Activar_Logs and (Log_Level >= L_Verbose)) then begin Registro_Log(Archivo_Logs,Prefix,'Registrar_Cliente - URL : ' + UnicodeString(G_Server_URL)); end; Poll.Enabled := False; // Paro Timer para no pisar respuestas if Respuesta_Pendiente then // Solo a Efectos de evitar supoerposiciones de comandos begin With Mod_Auxiliar do if (Activar_Logs and (Log_Level >= L_Debug)) then begin Registro_Log(Archivo_Logs,Prefix,'Registrar_Cliente - Esperando Respuesta Pendiente'); end; Timeout_Registro := False; TO_Registro.Interval := 5000; TO_Registro.Enabled := True; Repeat Application.HandleMessage; Demora(25); Until ((Not Respuesta_Pendiente) OR (Timeout_Registro)); TO_Registro.Enabled := False; end; Respuesta_Pendiente := True; // Ahora lo Congelo PAra mi CCDataTest := wst_CreateInstance_ServicePortType('SOAP:', 'HTTP:',G_Server_URL); // Revisamos Parametros if Parametro.LocationID = '' then begin FDato_Valido := True; FResultado := S2S_ANS_Location_ID_Invalido; LResultado := ClientRegisterRS.Create; LResultado.ResponseDesc := 'Location_ID Invalido'; LResultado.ResponseCode := S2S_ANS_Location_ID_Invalido; LResultado.SeqNum := 0; With Mod_Auxiliar do if (Activar_Logs and (Log_Level >= L_Info)) then begin Registro_Log(Archivo_Logs,Prefix,'Registrar_Cliente - Location ID - INVALIDO'); end; Result.ResponseCode := LResultado.ResponseCode; Result.ResponseDesc := LResultado.ResponseDesc; Result.SeqNum := LResultado.SeqNum; LResultado.Free; FRe_Enter := False; RX_TO.Enabled := False; Respuesta_Pendiente := False; // Ahora lo libero Poll.Enabled := True; // Largo Timer Exit; end; if Parametro.SeqNumRQ = 0 then begin FDato_Valido := True; LResultado := ClientRegisterRS.Create; LResultado.ResponseCode := S2S_ANS_SEQ_NUM_Invalido; LResultado.ResponseDesc := 'Secuence Number Invalido'; LResultado.SeqNum := 0; With Mod_Auxiliar do if (Activar_Logs and (Log_Level >= L_Info)) then begin Registro_Log(Archivo_Logs,Prefix,'Registrar_Cliente - Seq_Num - INVALIDO'); end; Result.ResponseCode := LResultado.ResponseCode; Result.ResponseDesc := LResultado.ResponseDesc; Result.SeqNum := LResultado.SeqNum; LResultado.Free; FRe_Enter := False; RX_TO.Enabled := False; Respuesta_Pendiente := False; // Ahora lo libero Poll.Enabled := True; // Largo Timer Exit; end; Fregistrando := True; With Mod_Auxiliar do if (Activar_Logs and (Log_Level >= L_Verbose)) then begin Registro_Log(Archivo_Logs,Prefix,'Registrar_Cliente - Parametros de Conexión OK'); end; LResultado := ClientRegisterRS.Create; try LResultado := CCDataTest.ClientRegisterRQ(Parametro); except on E : Exception do begin LResultado.ResponseDesc := UnicodeString(E.Message); LResultado.ResponseCode := S2S_COMM_ERROR; LResultado.SeqNum := 0; FStatus := S2S_COMM_ERROR; FRe_Enter := False; FDato_Valido := True; With Mod_Auxiliar do if (Activar_Logs and (Log_Level >= L_Info)) then begin Registro_Log(Archivo_Logs,Prefix,'Registrar_Cliente - Exception : ' + UnicodeString(E.Message)); end; Respuesta_Pendiente := False; Result.ResponseCode := LResultado.ResponseCode; Result.ResponseDesc := LResultado.ResponseDesc; Result.SeqNum := LResultado.SeqNum; LResultado.Free; exit; end; end; Respuesta_Pendiente := False; FRegistrando := False; RX_TO.Enabled := False; Result.ResponseCode := LResultado.ResponseCode; Result.ResponseDesc := LResultado.ResponseDesc; Result.SeqNum := LResultado.SeqNum; LResultado.Free; FDato_Valido := True; FResultado := Result.ResponseCode; FRe_Enter := False; With Mod_Auxiliar do if (Activar_Logs and (Log_Level >= L_Debug)) then begin Registro_Log(Archivo_Logs,Prefix,'Registrar_Cliente - Response Code : ' + UnicodeString(IntToStr(Result.ResponseCode))); Registro_Log(Archivo_Logs,Prefix,'Registrar_Cliente - Response Desc : ' + Result.ResponseDesc); end; if (Result.ResponseCode = 0) AND (FResultado = 0) then begin FStatus := S2S_REGISTRADO; Equipo.Seq_Num := Result.SeqNum; With Mod_Auxiliar do if (Activar_Logs and (Log_Level >= L_Debug)) then begin Registro_Log(Archivo_Logs, Prefix,'Registrar_Cliente - REGISTRADO OK'); end; end else if FStatus > 0 then begin FStatus := S2S_DESREGISTRADO; With Mod_Auxiliar do if (Activar_Logs and (Log_Level >= L_Info)) then begin Registro_Log(Archivo_Logs,Prefix,'Registrar_Cliente - DESREGISTRADO'); Registro_Log(Archivo_Logs,Prefix,'Registrar_Cliente - ResponseCode : ' + UnicodeString(IntToStr(FResultado))); end; end; Poll.Enabled := True; // Habilito Timer de Polling nuevamente Respuesta_Pendiente := False;end;
Cuando analizo los logs, siempre me encuentro con esta EXCEPCION
[vie 16 abr, 11:32:27.822] : - S2S - Version de DLL : 4.0.153.2661
[vie 16 abr, 11:32:27.826] : - S2S - Plataforma : i386 - Win32
[vie 16 abr, 11:32:27.827] : - S2S - Fecha Compilacion : 2021/04/15 - 16:24:48
[vie 16 abr, 11:32:27.828] : - S2S - Datos de Conexion : https:////XXXXXXXX:8443/YYYYYYYYY/Service
[vie 16 abr, 11:32:27.828] : - S2S - Registrando Cliente
[vie 16 abr, 11:32:27.830] : - S2S - Registrar_Cliente - Exception : HTTP Request to https://XXXXXXXX:8443/YYYYYYYYY/Service -> failed.
Insisto en que con la otra libreria en Delphi, la respuesta es correcta en tiempo y forma.
Por otro lado, el Servicio fue importado via la utilidad Web Services Tool Kit.
Mi sospecha está orientada a esta instrucción, pero la verdad ya he probado de todo y sigo sin poder conectarme.
CCDataTest := wst_CreateInstance_ServicePortType('SOAP:', 'HTTP:',G_Server_URL);
Donde:
G_Server_URL = "https:////XXXXXXXX:8443/YYYYYYYYY/Service";
Como controladores de Protocolo he usado, en ambos casos sin éxito:
indy_http_protocol y fpc_http_protocol
Finalmente, un último comentario, el HTTP funciona SIN NINGÚN INCONVENIENTE.
Es lo único que me imposibilita la migración de plataforma, con lo cual toda ayuda o comentario seria de suma utilidad.
Agradezco desde ya el tiempo.
GAN:
Hola, no soy especialista en el tema, pero envío archivos vía FTP sin problemas usando las unidades ftpsend, blcksock de Synapse.
En otro programa, para leer páginas webs utilizo las unidades fphttpclient (RTL) y openssl (Synapse).
Synapse comenzó con Delphi y hace rato es compatible con Free Pascal.
Saludos.
FOV_2001:
Hola GAN, gracias por tu tiempo.
Lamentablemente el WEB SERVICE lado Server, no lo hice yo, y no tengo mas remedio que consumirlo. No puedo usar otro metodo. y Via Synapse, estoy bastante lego. Asi que estoy tratando de seguir pasos mas o menos parecidos a los que uso en Delphi.
Como dije, mi experiencia viene de ahi, y funciona perfecto. Esto sin duda debe ser una tonteria, pero la verdad es que ya no se donde buscar.
De cualquier forma voy a investigar el tema.
Te agradezco nuevamente tu tiempo
FOV_2001:
GAN buenas tardes,
Luego de seguir tu consejo, Synapse tiene su openSSL, y llego a otro callejón.
el OpenSSL lo tengo instalado pero al instanciar
SYNAPSE_RegisterHTTP_Transport();
No encuentro como habilitar la etapa de encripcion y decirle que la use.
Sinb dua me has mostrado una idea a descubrir.
De cualquier manera, debido a lo basico de mi problema agradezco te hayas tomado el tiempo de darme una mano.
Seguiré buscando
GRACIAS
GAN:
Qué tal FOV_2001, sí te recomendé Synapse por ese tema OpenSSL además que era el que te faltaba probar.
En mi caso, el uso limitado que le doy y los pocos conocimientos que tengo en el tema, sé que la unidad debe estar presente, creo que la usa "internamente" Synapse, pero "creo", ahí hay que buscar documentación, no queda otra.
Algunos links:
Synapse How to: http://synapse.ararat.cz/doku.php/public:howto
Synapse TCP/IP client and server (foro): https://forum.lazarus.freepascal.org/index.php/topic,48677.0.html
Wiki Lazarus / Free Pascal: https://wiki.lazarus.freepascal.org/Synapse
Suerte!
Navigation
[0] Message Index
[#] Next page