FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Restful API
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Restful API
Posted: Mon Nov 12, 2018 05:30 PM

To All

I have seen a few threads on this topic .. I may have an opportunity to communicate between two different applications via the RestFul Api ... I would be most grateful if anyone could point me to any documentation and possibly any Harbour\xHarbor code or classes that anyone has created that I could leverage to see if it is possible to communicate between two applications.

Thanks
Rick Lipkin

Posts: 140
Joined: Thu Feb 02, 2006 12:09 PM
Re: Restful API
Posted: Mon Nov 12, 2018 07:04 PM

regards
from the client side hbcurl. / harbor / contrib / hbcurl the good thing is that you can then solve anything with hbcurl restful-apis-ftp-xml-json-ssl etc.

the examples that are there worked correctly for me.

viewtopic.php?f=3t=33123p=195146hilit=curl#p195118

and add link these two libraries
echo c:\hbcurl\hbcurl.lib + >> b32.bc
echo c:\hbcurl\libcurl.lib + >> b32.bc

from the server side in harbor hbhttpd I recommend this video only that is in Spanish.

https://www.youtube.com/watch?v=ivWorfpnnMs

&&&

Mario Antonio Gonz谩lez Osal

Venezuela

m a g 0 7 1 @ g m a i l. c o m
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Restful API
Posted: Mon Nov 12, 2018 07:45 PM
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 989
Joined: Thu Nov 24, 2005 03:01 PM
Re: Restful API
Posted: Fri Nov 16, 2018 06:56 PM
Hi Rick,
Rick Lipkin wrote:
I have seen a few threads on this topic .. I may have an opportunity to communicate between two different applications via the RestFul Api ... I would be most grateful if anyone could point me to any documentation and possibly any Harbour\xHarbor code or classes that anyone has created that I could leverage to see if it is possible to communicate between two applications.

Let me point sth about Rest APIs. AFAIK, in a Rest API there are 2 roles, a sever and a client, so if your plan is to communicate 2 apps then both will have to act as both server and client. Said this, count my +1 to the use of curl for the client side, it is the most complete, manteined and updated library, available in all platforms, so you will find lots of code samples do to whatever you want. So far I've used curl to do http(s), ftp and a great webdav client to replace an insecure ftp connection.
For the server, the current solution is using the contrib httpd. Rafa Carmona shared a repo in Github with a sample server. https://github.com/rafathefull/restful
To design the API interface and endpoints, there is an outstanding stardard to follow, OAS Open API Specification, and wonderful tools that support it.
For design: Swagger Editorhttps://swagger.io/tools/swagger-editor/. You describe every endpoint of the service using YAML in the Swagger editor an it will write the documentacion simultaneously, test tools, etc.
For testing your REST server, I use Postman https://www.getpostman.com/
Saludos
Carlos Mora
http://harbouradvisor.blogspot.com/
StackOverflow http://stackoverflow.com/users/549761/carlos-mora
鈥淚f you think education is expensive, try ignorance"
Posts: 1283
Joined: Fri Feb 10, 2006 02:34 PM
Re: Restful API
Posted: Fri Nov 16, 2018 11:05 PM

Hola,

Mi punto de vista es el siguiente, hoy en dia nuestras aplicaciones windows se han de expandir en un escenario fuera de nuestra red interna. Esto se llama Internet. Si queremos conectarnos a nuestras bases de datos centralizadas en un hosting con nuestra aplicaciones windows la mejor opci贸n y mas segura es via webservice y para ello curl es para mi la mejor opci贸n . Porque ? Porque hemos de empezar a cambiar nuestra manera de pensar y saber que mucha parte del negocio de nuestra aplicaci贸n no estar谩 integrado en nuestro exe sino en el cloud. Nuestras aplicaciones (win/web/app) habran de conectarse a este cloud y crear unas llamadas a unos servicios para gestionar nuestras acciones y la mejor manera es via webservice y para ello podemos usar curl como dice Carlos Mora, y estoy completamente de acuerdo.

En estos foros se pueden ver tips sobre conectar directamente con las bases de datos con diferentes librerias, en especial mysql. En entornos peque帽os de negocio y red interna quizas sea una soluci贸n valida pero no a nivel internet. Yo creo que esto es un error !. Evidentemente lo podemos hacer tecnicamente, incluso en un entorno peque帽o de negocio es lo mas f谩cil, pero si queremos "externalizar" todo/parte de nuestro negocio hemos de tener presente la seguridad de nuestros datos. Una de las grandes questiones es: conectarse directamente a mysql vs. webservices.

El dise帽o de un peque帽o webservice Restful permite integrar una capa de seguridad junto con la posibilidad que diferentes tecnologias y sistemas se puedan conectar de la misma manera con un protocolo que permita compartir sus funcionalidades.

Si tu dise帽as un peque帽o webservice para actualizar un stock, podras desde FWH + CURL gestionarlos e igualmente desde WEB CURL gestionarlo...

Por muy f谩cil que sea conectarse por ejemplo a mysql directamente (base de datos mas popular) recomiendo por motivos de seguridad, escalabilidad, mantenimiento... aprender a crear webservices. Hay muchos ejemplos en el foro de conexion via curl. El negocio no esta en el exe encapsulado e incrustado, sino en el cloud....

mis 2 centavos...

Buen fin de semana :-)

Salutacions, saludos, regards

"...programar es f谩cil, hacer programas es dif铆cil..."

UT Page -> https://carles9000.github.io/
Forum UT -> https://discord.gg/bq8a9yGMWh
HIX -> https://github.com/carles9000/hix
Posts: 989
Joined: Thu Nov 24, 2005 03:01 PM
Re: Restful API
Posted: Sat Dec 08, 2018 11:13 AM
A little bit out of topic, but to back the idea of using cUrl as a library: CURL in included in Windows 10! I can't tell how long it has been there, but it is. Just open a console window and write 'curl'

Code (fw): Select all Collapse
Microsoft Windows [Versi贸n 10.0.17134.407]
(c) 2018 Microsoft Corporation. Todos los derechos reservados.

C:\Users\Carlos>curl
curl: try 'curl --help' for more information

C:\Users\Carlos>

more info:
https://blogs.technet.microsoft.com/vir ... o-windows/
Saludos
Carlos Mora
http://harbouradvisor.blogspot.com/
StackOverflow http://stackoverflow.com/users/549761/carlos-mora
鈥淚f you think education is expensive, try ignorance"
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: Restful API
Posted: Mon Mar 15, 2021 05:34 PM
cnavarro wrote:This was mine

https://www.youtube.com/watch?v=i795dnTc-1Y&t=4697s

https://bitbucket.org/fivetech/harbour_ ... o_REST.pdf


Hi Mr. Navarro,

Is there any documentation server side of restfull api in english?

Thanks.
Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Restful API
Posted: Mon Mar 15, 2021 08:02 PM

Dear Hakan, no, sorry, I have not had time to translate it, but any help you need, I will be happy to help you well here in the forum or by mail if they are topics that cannot be published.

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: Restful API
Posted: Tue Mar 16, 2021 06:32 AM
cnavarro wrote:Dear Hakan, no, sorry, I have not had time to translate it, but any help you need, I will be happy to help you well here in the forum or by mail if they are topics that cannot be published.


Thank you very much Mr. Navarro.

I understand there is two side to restfull api. Client side and Server Side.

I am interested in server side like webservice. Should I install web server application. Which one? I looking for information to start.
Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Restful API
Posted: Tue Mar 16, 2021 07:40 AM
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: Restful API
Posted: Tue Mar 16, 2021 10:18 AM
Dear Antonio,

Thank you very much for your info.
Please look, this is how I collect your information.
Best regards,
Otto

https://mybergland.com/fwforum/baustein.mp4
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: Restful API
Posted: Tue Mar 16, 2021 11:16 AM
Antonio Linares wrote:Building the simplest webservice using mod_harbour:
https://github.com/FiveTechSoft/mod_harbour/blob/master/samples/webservice.prg

Using the above webservice using mod_harbour:
https://github.com/FiveTechSoft/mod_harbour/blob/master/samples/callwebservice.prg


Hi Antonio,

You say The installation of mod harbour first, I understand.

Thank you.
Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Restful API
Posted: Tue Mar 16, 2021 03:58 PM
Hakan,

To use mod_harbour, you have to install it first on a server:
https://github.com/FiveTechSoft/mod_harbour

or use the mod_harbour live demo:
https://www.modharbour.org/modharbour_samples/modpro/modpro.prg

You can also hire a mod_harbour server with everything installed and ready to use it:
https://xbhosts.com/
regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion