Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 8150

How to get Client IP address from ABAP

$
0
0

Hi Everyone,


We are lunching the module pool program from SAP Portal.  Inside module pool program we are fetching the client IP using below code and it was working fine before with "~REMOTE_ADDR"  header field. Now my client replaced the new Load dispatcher. After this change my code giving the Load dispatcher IP and not the client IP.


I am trying use "X-Forwarded_For" header filed to get client IP. But i did not find "X-Forwarded_For" field in my response header fields and i can  see "~REMOTE_ADDR"  header filed which giving theLoad dispatcher IP and my basis team confirmed they have done required setting to forward client IP.


To check basis setting correct or not, I have developed BSP application and displaying header fields. when run BSP application from browser . I can  see "X-Forwarded_For" header filed with client.   


i have tried BSP Application URL in the below code also, But no use still we didn't find "X-Forwarded_For".

 

I have tried SICF service Node URL in the below code also, But no use still we didn't find "X-Forwarded_For".

 

Please help me, how i can get the Client IP. 

TRY.

*     Create the URL

       CALL METHOD cl_http_client=>create_by_url

         EXPORTING

           url    = 'http://xxxx.services.xxx.ae/irj/portal'

           ssl_id = ' '

         IMPORTING

           client = lo_client

         EXCEPTIONS

           OTHERS = 1.

 

    IF sy-subrc IS INITIAL.

 

*     Make the call

         lo_client->send( ).

 

*     Receive the Response Object


         CALL METHOD lo_client->receive

           EXCEPTIONS

             http_communication_failure = 1

             http_invalid_state         = 2

             http_processing_failed     = 3

             OTHERS                     = 4.

 


*         Read the IP from Header fields


           ev_ip_address = lo_client->response->get_header_field( name  = 'X-Forwarded_For').


*     Close connection

         lo_client->close( ).


       ENDIF.

 


Viewing all articles
Browse latest Browse all 8150


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>