Four Js Development Tools Forum

Discussions by product => GWS => Topic started by: Nuno T. on April 29, 2019, 10:50:27 am



Title: How to get client's IP address restful or soap?
Post by: Nuno T. on April 29, 2019, 10:50:27 am
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.


Title: Re: How to get client's IP address restful or soap?
Post by: 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 (https://4js.com/online_documentation/fjs-fgl-manual-html/#fgl-topics/c_gws_ComHTTPServiceRequest_getRequestHeader.html)


Title: Re: How to get client's IP address restful or soap?
Post by: Reuben B. on May 01, 2019, 01:44:21 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 (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.


Title: Re: How to get client's IP address restful or soap?
Post by: 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


Title: Re: How to get client's IP address restful or soap?
Post by: Reuben B. on May 03, 2019, 10:47:54 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
  1. FUNCTION add(
  2.    a INTEGER ,
  3.    b INTEGER
  4.    )
  5.    RETURNS INTEGER
  6.  
  7. DEFINE c INTEGER
  8.  
  9.    LET c = a + b
  10.    RETURN c
  11. END FUNCTION
  12.  

can have a few attributes added

Code
  1. FUNCTION add(
  2.    a INTEGER ATTRIBUTES(WSParam),
  3.    b INTEGER ATTRIBUTES(WSParam)
  4.    )
  5.    ATTRIBUTES (WSGet, WSPath="/Add/{a}/{b}")
  6.    RETURNS INTEGER
  7.  
  8. DEFINE c INTEGER
  9.  
  10.    LET c = a + b
  11.    RETURN c
  12. END FUNCTION
  13.  

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