Responding to an HTTP Request

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Responding to an HTTP Request

4D Tech mailing list
I’m just starting to do some 4D web development and have a simple question.

The 4D app I’m working on needs to respond to a REST call by acknowledging it and sending a status (200 would work). When the REST call comes into the 4D Web Server I handle it in On Web Connection. That part is working fine, but I need to acknowledge receipt so the calling app/service won’t keep retrying. This seems like it should be pretty straightforward, but I’m at a loss to know where to start. I know I need to build a status line and header line, but ‘how’ do I send it? Do I use  some form of HTTP Request? Or do I need to build something with 4DIC? Or something else?

If someone could point me to a resource that can enlighten me I’d appreciate it.

Thanks,

Tom Benedict



**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: Responding to an HTTP Request

4D Tech mailing list
Tom,

A simple minimal example of how to respond would be something like this:

ARRAY TEXT($aHeaderFields;3)
ARRAY TEXT($aHeaderValues;3)

$aHeaderFields{1}:="X-VERSION"
$aHeaderFields{2}:="X-STATUS"
$aHeaderFields{3}:="USER-AGENT"

$aHeaderValues{1}:="HTTP/1.0"
$aHeaderValues{2}:="200 OK"
$aHeaderValues{3}:="4D Web Server/v17"

WEB SET HTTP HEADER($aHeaderFields;$aHeaderValues)
WEB SEND TEXT("")

Check out the 4D Web Server docs for more details:
https://doc.4d.com/4Dv17/4D/17.3/Web-Server.201-4620181.en.html

Regards,
Narinder Chandi,
ToolBox Systems Ltd.
https://toolbox.systems
 
I am available for new consulting opportunities…
http://4d.1045681.n5.nabble.com/ANN-4D-Developer-Available-td5765443.html
--

-----Original Message-----
From: 4D_Tech <[hidden email]> on behalf of 4D Tech Mailing List <[hidden email]>
Reply-To: 4D Tech Mailing List <[hidden email]>
Date: Saturday, 26 October 2019 at 04:29
To: 4D Tech Mailing List <[hidden email]>
Cc: Tom Benedict <[hidden email]>
Subject: Responding to an HTTP Request

    I’m just starting to do some 4D web development and have a simple question.
   
    The 4D app I’m working on needs to respond to a REST call by acknowledging it and sending a status (200 would work). When the REST call comes into the 4D Web Server I handle it in On Web Connection. That part is working fine, but I need to acknowledge receipt so the calling app/service won’t keep retrying. This seems like it should be pretty straightforward, but I’m at a loss to know where to start. I know I need to build a status line and header line, but ‘how’ do I send it? Do I use  some form of HTTP Request? Or do I need to build something with 4DIC? Or something else?
   
    If someone could point me to a resource that can enlighten me I’d appreciate it.
   
    Thanks,
   
    Tom Benedict
   
   
   
    **********************************************************************
    4D Internet Users Group (4D iNUG)
    Archive:  http://lists.4d.com/archives.html
    Options: https://lists.4d.com/mailman/options/4d_tech
    Unsub:  mailto:[hidden email]
    **********************************************************************


**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: Responding to an HTTP Request

4D Tech mailing list
In reply to this post by 4D Tech mailing list
Actually, just doing a WEB SEND TEXT(“”) at some point in your code will send a 200 status. All you need is to reply to the incoming request.

> On Oct 26, 2019, at 12:29 AM, Tom Benedict via 4D_Tech <[hidden email]> wrote:
>
> I’m just starting to do some 4D web development and have a simple question.
>
> The 4D app I’m working on needs to respond to a REST call by acknowledging it and sending a status (200 would work). When the REST call comes into the 4D Web Server I handle it in On Web Connection. That part is working fine, but I need to acknowledge receipt so the calling app/service won’t keep retrying. This seems like it should be pretty straightforward, but I’m at a loss to know where to start. I know I need to build a status line and header line, but ‘how’ do I send it? Do I use  some form of HTTP Request? Or do I need to build something with 4DIC? Or something else?
>
> If someone could point me to a resource that can enlighten me I’d appreciate it.
>
> Thanks,
>
> Tom Benedict
>

--
Julio Carneiro
[hidden email]




**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: Responding to an HTTP Request

4D Tech mailing list
In reply to this post by 4D Tech mailing list
Thanks Narinder and Julio.

That did it! Evidently the 4D Web Server knows where to send the header without being explicitly told. Maybe it has a queue? I guess it doesn’t really matter as long as it works.

So it appears that I can use HTTP Client commands for ‘outbound’ REST calls and use Web Server commands to respond to ‘inbound’ REST calls. Does that sound right?

Thanks again,

Tom

> On Oct 26, 2019, at 02:40, Narinder Chandi via 4D_Tech <[hidden email]> wrote:
>
> Tom,
>
> A simple minimal example of how to respond would be something like this:
>
> ARRAY TEXT($aHeaderFields;3)
> ARRAY TEXT($aHeaderValues;3)
>
> $aHeaderFields{1}:="X-VERSION"
> $aHeaderFields{2}:="X-STATUS"
> $aHeaderFields{3}:="USER-AGENT"
>
> $aHeaderValues{1}:="HTTP/1.0"
> $aHeaderValues{2}:="200 OK"
> $aHeaderValues{3}:="4D Web Server/v17"
>
> WEB SET HTTP HEADER($aHeaderFields;$aHeaderValues)
> WEB SEND TEXT("")
>
> Check out the 4D Web Server docs for more details:
> https://doc.4d.com/4Dv17/4D/17.3/Web-Server.201-4620181.en.html
>
> Regards,
> Narinder Chandi,
> ToolBox Systems Ltd.
> https://toolbox.systems
>
> I am available for new consulting opportunities…
> http://4d.1045681.n5.nabble.com/ANN-4D-Developer-Available-td5765443.html
> --
>
> -----Original Message-----
> From: 4D_Tech <[hidden email]> on behalf of 4D Tech Mailing List <[hidden email]>
> Reply-To: 4D Tech Mailing List <[hidden email]>
> Date: Saturday, 26 October 2019 at 04:29
> To: 4D Tech Mailing List <[hidden email]>
> Cc: Tom Benedict <[hidden email]>
> Subject: Responding to an HTTP Request
>
>    I’m just starting to do some 4D web development and have a simple question.
>
>    The 4D app I’m working on needs to respond to a REST call by acknowledging it and sending a status (200 would work). When the REST call comes into the 4D Web Server I handle it in On Web Connection. That part is working fine, but I need to acknowledge receipt so the calling app/service won’t keep retrying. This seems like it should be pretty straightforward, but I’m at a loss to know where to start. I know I need to build a status line and header line, but ‘how’ do I send it? Do I use  some form of HTTP Request? Or do I need to build something with 4DIC? Or something else?
>
>    If someone could point me to a resource that can enlighten me I’d appreciate it.
>
>    Thanks,
>
>    Tom Benedict
>
**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: Responding to an HTTP Request

4D Tech mailing list
    So it appears that I can use HTTP Client commands for ‘outbound’ REST calls and use Web Server commands to respond to ‘inbound’ REST calls. Does that sound right?
Correct.

I recently did an e-commerce integration piece into PayPal and it was my first spin with the HTTP Client/Web Server commands. I've previously done lots of similar work with PHP before which helped with orientating oneself but working in the context of 4D was a good experience and the commands are easy to get to grips with. Good luck!

Regards,
Narinder Chandi,
ToolBox Systems Ltd.
https://toolbox.systems
 
I am available for new consulting opportunities…
http://4d.1045681.n5.nabble.com/ANN-4D-Developer-Available-td5765443.html
--



**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************