Subject Re: Creating Webserver to process Http APIs - 1 attachment
From Boris Borzic <.> <Boris Borzic <.>>
Date Thu, 1 Jul 2021 11:19:59 -0400
Newsgroups xb2net
Attachment(s) json_ws_test.prg

Osvaldo Aoki <osvaldo.aoki@aokisistemas.com.br> wrote in
news:s0nb1y3nkqpzeul.300620211443@BACKUP:

>    I am a Software ERP developer wrotten in Alaska Xbase.
>    I am analyzing Xb2Net to create a program to receive API Call (Web
>    Services - JSON), and process them, return result to the caller.
>    For each received Call, I think to create a Thread to attend and
>    process API separated. In My system, I just have a Program that
>    keep in Looping to processo all request IN and attend API Web
>    service. I just want to know if any people already do it, and if
>    this idea is possible to implement. Thanks

This is extremely easy to do with Xb2.NET - use the sample WEBSERVE.PRG as
your starting point.

Attached is a very simple JSON server-side PRG script. Copy the attached
file into your .\www_root folder and call the function from your JSON
client. If the client is running on the same computer as the server the URL
will be this:

http://localhost/json_ws_test.prg

Note that you can execute this from a browser. The PRG will be compiled,
but you will get the following message: "Method Not Allowed". The reason is
the web service function is expecting a POST with content-type:
"application/json".

When the request comes in as a POST with content-type "application/json",
the server returns the following JSON message:

{"body":{"success":true},"header":{"message":"OK","msgCode":"200"}}

--
Best regards,
Boris Borzic

http://xb2.net
http://sqlexpress.net
industrial strength Xbase++ development tools


Recent messages in this thread
 
-# Creating Webserver to process Http APIs Osvaldo Aoki 30-Jun-2021 02:43 pm
.\# Re: Creating Webserver to process Http APIs - 1 attachment (Current message) Boris Borzic <.> 01-Jul-2021 11:19 am