Restful API

Post Reply
User avatar
Rick Lipkin
Posts: 2397
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Restful API

Post by Rick Lipkin »

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
User avatar
mag071
Posts: 139
Joined: Thu Feb 02, 2006 12:09 pm
Location: Venezuela
Contact:

Re: Restful API

Post by mag071 »

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.
http://forums.fivetechsupport.com/viewt ... rl#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
User avatar
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Restful API

Post by cnavarro »

C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
Carlos Mora
Posts: 988
Joined: Thu Nov 24, 2005 3:01 pm
Location: Madrid, España

Re: Restful API

Post by Carlos Mora »

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
“If you think education is expensive, try ignorance"
User avatar
Carles
Posts: 937
Joined: Fri Feb 10, 2006 2:34 pm
Location: Barcelona
Contact:

Re: Restful API

Post by Carles »

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..."

https://modharbour.app
https://modharbour.app/compass
https://forum.modharbour.app
Carlos Mora
Posts: 988
Joined: Thu Nov 24, 2005 3:01 pm
Location: Madrid, España

Re: Restful API

Post by Carlos Mora »

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: Select all

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
“If you think education is expensive, try ignorance"
Post Reply