Page 1 of 1

Restful API

Posted: Mon Nov 12, 2018 5:30 pm
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

Re: Restful API

Posted: Mon Nov 12, 2018 7:04 pm
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

Re: Restful API

Posted: Mon Nov 12, 2018 7:45 pm
by cnavarro

Re: Restful API

Posted: Fri Nov 16, 2018 6:56 pm
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/

Re: Restful API

Posted: Fri Nov 16, 2018 11:05 pm
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 :-)

Re: Restful API

Posted: Sat Dec 08, 2018 11:13 am
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/