Servidor en localhost

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
Mario Mansilla
Posts: 271
Joined: Wed Aug 13, 2008 2:35 pm
Location: Córdoba - Argentina

Servidor en localhost

Post by Mario Mansilla »

Hola Amigos :
Tengo una aplicacion realizada con HmG 3.4.4 32 bits y necesito conectarla a una API que devuelve los resultados en una url . Como mi aplicacion es de escritorio necesito crear un servidor que espere resultados en la direccion http:\\localhost:8080\Callback .
Intento con esta funcion ayudado por IA pero al intentar compilar me da error en la funcion hb_httpdReceiver .
No se donde estoy cometiendo el error , espero puedan orientarme .
Adjunto las funciones que intento utilizar

Saludos
Mario Rafael Mansilla

Hello Friends:
I have an application built with HmG 3.4.4 32-bit and I need to connect it to an API that returns results to a URL. Since my application is desktop-based, I need to create a server that expects results at the address http:\\localhost:8080\Callback.
I'm trying to use this function with AI assistance, but when I try to compile, I get an error in the hb_httpdReceiver function.
don't know where I'm going wrong; I hope you can guide me.
I've attached the functions I'm trying to use.
Regards, Mario Rafael Mansilla

Harbour 3.2.0dev (r1703241902)
Copyright (c) 1999-2016, http://harbour-project.org/
C:/Users/Usuario/AppData/Local/Temp/hbmk_7cxa8p.dir/Main.o:Main.c:(.data+0xb8): undefined reference to `HB_FUN_HBHTTPDRECEIVER'
collect2.exe: error: ld returned 1 exit status
hbmk2[Main]: Error: Ejecutando enlazador. 1
gcc.exe C:/Users/Usuario/AppData/Local/Temp/hbmk_7cxa8p.dir/Main.o C:/Users/Usuario/AppData/Local/Temp/hbmk_7cxa8p.dir/hbmk_f1wpne.o C:/Sistemas/TfwinNube/_temp.o -pthread -static-libgcc -static-libstdc++ -static -lpthread -mwindows -Wl,--start-group -lhmg -lcrypt -ledit -leditex -lgraph -lini -lreport -lhfcl -lmsvfw32 -lvfw32 -lhbmysql -lmysql -lhbfimage -lhbpgsql -lsddmy -lhbvpdf -lhbct -lhbwin -lhbmzip -lminizip -lhbmemio -lhbmisc -lhbtip -lsqlite3 -lhbsqlit3 -lsddodbc -lrddsql -lhbodbc -lodbc32 -lhbhpdf -lhbnetio -lxhb -lpng -llibhpdf -lhbzebra -lhbssl -lssleay32 -llibeay32 -lhbhttpd -lhbextern -lhbdebug -lhbvm -lhbrtl -lhblang -lhbcpage -lgtcgi -lgtpca -lgtstd -lgtwin -lgtwvt -lgtgui -lhbrdd -lhbuddall -lhbusrrdd -lrddntx -lrddcdx -lrddnsx -lrddfpt -lhbrdd -lhbhsx -lhbsix -lhbmacro -lhbcplr -lhbpp -lhbcommon -lhbmainwin -lkernel32 -luser32 -lgdi32 -ladvapi32 -lws2_32 -liphlpapi -lwinspool -lcomctl32 -lcomdlg32 -lshell32 -luuid -lole32 -loleaut32 -lmpr -lwinmm -lmapi32 -limm32 -lmsimg32 -lwininet -lhbpcre -lhbzlib -Wl,--end-group -oMain.exe -LC:/hmg.3.4.4/harbour/lib/win/mingw -LC:/hmg.3.4.4/lib

hbmk2: Error: Funci¢n(es) referenciada, no encontrada, pero desconocida:
HBHTTPDRECEIVER()

Uso HMG 3.4.4 32 bits con su respectivo ide . En configuracion agrego las librerias :

I'm using HMG 3.4.4 32-bit with its respective IDE. In the configuration, I've added the following libraries:

libs=hbtip.hbc
libs=hbssl.hbc
libs=hbhttpd.hbc


*--------------------------
FUNCTION StartLocalServer()
*--------------------------
LOCAL nPort := 8080
LOCAL oHttpd

// Iniciamos el servidor en el puerto 8080
// El segundo parámetro es el bloque de código que procesa las peticiones
oHttpd := hb_httpdReceiver( nPort, { | oRequest | ProcessRequest( oRequest ) } )

IF Empty( oHttpd )
MsgStop( "No se pudo iniciar el servidor en el puerto " + hb_ntos(nPort) )
ELSE
MsgInfo( "Servidor escuchando en http://localhost:" + hb_ntos(nPort) + "/callback" )
ENDIF
RETURN NIL

*---------------------------------------
STATIC FUNCTION ProcessRequest( oRequest )
*---------------------------------------

LOCAL cPath := oRequest:GetEnv( "PATH_INFO" )
LOCAL cResponse := ""

// Verificamos si la ruta es /callback
IF cPath == "/callback"
// Aquí procesas lo que llega (parámetros GET, POST, etc.)
cResponse := "<html><body><h1>Callback recibido con éxito</h1></body></html>"

// Ejemplo: registrar en log o mostrar mensaje en MiniGUI
// DoMethod( "Form_1", "StatusBar", "Item", 1, "Petición recibida en /callback" )
ELSE
cResponse := "<html><body><h1>404 - Ruta no encontrada</h1></body></html>"
ENDIF

// Enviamos la respuesta al cliente
oRequest:SendResponse( cResponse )
RETURN NIL
User avatar
serge_girard
Posts: 3392
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Servidor en localhost

Post by serge_girard »

Mario,

hb_httpdReceiver

unknown function!

Is the API already working? Can you call the API from a browser?

Best option is to use CURL !

I use this command

Code: Select all

cBTW := 'BE12121212121' 
cUrl := "https://controleerbtwnummer.eu/api/validate/" + cBTW + ".json"
Then I send cURL with CURL and interpret result. Is it something like this you want?

Serge
There's nothing you can do that can't be done...
Post Reply