Subscribe for automatic updates: RSS icon RSS

Login icon Sign in for full access | Help icon Help
Advanced search

Pages: [1]
  Reply  |  Print  
Author Topic: How to get client's IP address restful or soap?  (Read 14397 times)
Nuno T.
Posts: 14


« 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.
David H.
Posts: 158


« Reply #1 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
Reuben B.
Four Js
Posts: 1116


« Reply #2 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


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.
Posts: 14


« Reply #3 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
Reuben B.
Four Js
Posts: 1116


« Reply #4 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







Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines