How to get client's IP address restful or soap?

Started by Nuno T., April 29, 2019, 10:50:27 AM

Previous topic - Next topic

Nuno T.

Hi all,

Is there any chance to get client IP or hostname in web services server restful or soap in genero versions 3.10 or 3.20 ?

Thanks in advance.


Reuben B.

Quote from: David H. on April 29, 2019, 01:39:50 PM
Have a look at the contents of header " X-FourJs-Environment-Variable-REMOTE_ADDR"

https://4js.com/online_documentation/fjs-fgl-manual-html/#fgl-topics/c_gws_ComHTTPServiceRequest_getRequestHeader.html


This page in the GAS documentation provides a bit more information for the above. http://4js.com/online_documentation/fjs-gas-manual-html/#gas-topics/c_gas_fgl_application_environment.html#c_gas_fgl_application_environment__sec_gas_fgl_application_environment_GWS helps

Also the new high level RESTful web services coming in 3.20 will have another technique to get the same information. (the com.HttpServiceRequest object is hidden so you can't use the above technique to read the headers)  I'll try to remember to post a link here when 3.20 comes out.
Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero

Nuno T.

Thanks very much, now i understand how it works.

I understand that in 3.20 version i have to change my code to get the same result ?

Thanks
Nuno

Reuben B.

Quote from: Nuno T. on May 03, 2019, 09:51:42 AM
Thanks very much, now i understand how it works.

I understand that in 3.20 version i have to change my code to get the same result ?

Thanks
Nuno

You won't have to change code any code in 3.20.

In 3.20 we introduce an improved mechanism for writing RESTful Web Services.  To tease you a little, an existing function

Code (genero) Select
FUNCTION add(
    a INTEGER ,
    b INTEGER
    )
    RETURNS INTEGER

DEFINE c INTEGER

    LET c = a + b
    RETURN c
END FUNCTION


can have a few attributes added

Code (genero) Select
FUNCTION add(
    a INTEGER ATTRIBUTES(WSParam),
    b INTEGER ATTRIBUTES(WSParam)
    )
    ATTRIBUTES (WSGet, WSPath="/Add/{a}/{b}")
    RETURNS INTEGER

DEFINE c INTEGER

    LET c = a + b
    RETURN c
END FUNCTION


and with one or two more steps, that is now exposed as a RESTful Web Service.  However there is no com.HTTPServiceRequest object exposed, so for these there is another technique to get the headers.

I'll post more once 3.20 is released but for know you can join the EAP and evaluate these higher level RESTful Web Services.

Reuben






Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero