cancel
Showing results for 
Search instead for 
Did you mean: 

Get ip address from third-party system via UDF

Former Member
0 Kudos

Dear All,

I have a scenario from third-party system OA to ECC via PI. I need to get the IP address of OA via UDF or java mapping . How to achieve it ?

Thank you for your advice in advance.

Many thanks & best regards,

Hubery

Accepted Solutions (1)

Accepted Solutions (1)

former_member190293
Active Contributor
0 Kudos

Hi Hubery!

As per SAP help:

The following attributes are added to the XI message header if the sender makes them available, and if you select Variable Transport Binding .

  • Remote User : (technical name: SRemoteUser )
  • Remote Host : (technical name: SRemoteHost )
  • SOAP Action (technical name: SHeaderSOAPACTION )


Regards, Evgeniy.

Former Member
0 Kudos

Dear Evgeniy,

Thank you for your information. In fact, ECC will receive the data of IP address and store. But the receiver adapter RFC,the proxy do not need to activate.  so I am not sure how to get the SOAP HEADER data.

Could you please provide some advice to get the ip address?

Appreciate your input.

Many thanks & best regards,

Hubery

former_member190293
Active Contributor
0 Kudos

Hi Hubery!

Do you have any message mapping in your scenario?

If so, create UDF like this:

DynamicConfiguration dc = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey key = DynamicConfigurationKey.create("http:/"+"/sap.com/xi/XI/System/SOAP","SRemoteHost");
String val = dc.get(key);
if(val == null) val = "";
return val;

Regards, Evgeniy.

Former Member
0 Kudos

Yes, your solution is perfect. Thank you once again, Evgeniy.

Many thanks & best regards,

Hubery

Answers (4)

Answers (4)

Former Member
0 Kudos

Dear All,

Thank you all of you for your great support. Thank you for your enthusiasm and patience.

The process is the following for my condition:

1. Enabled the ASMA.

2. Added the UDF to get the IP address.

Many thanks & best regards,

Hubery

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Hubery,

Configuring the Sender SOAP Adapter - Advanced Adapter Engine - SAP Library

Use the technical name SRemoteHost when querying using ASMA.

Regards,

Mark

Former Member
0 Kudos

Dear Mark,

Thank you for your information. In fact, ECC will receive the data of IP address and store. I remember that there is a method with ABAP to get the SOAP HEADER data.

Thank you so much.

Hubery

bhavesh_kantilal
Active Contributor
0 Kudos

Never tried this but a quick google provided me with multiple Java Sample Code references for this. One such is available here : Convert a hostname to the equivalent IP address : IP Address « Network P...

Former Member
0 Kudos

Dear Bhavesh,

Thank you for your reply. we need to dynamically get the ip address and handle the different business. So there is no filed to correspond the website or IP address.

Any solution is ok?

Hubery

bhavesh_kantilal
Active Contributor
0 Kudos

Hello Hubery,

- If I understand this right, you are planning to expose an Interface using a SOAP Sender adapter and there can be multiple systems that trigger this call to PI.

- Depending on the system that has triggered the call you would like to identify this in some mode and then process the same in PI?

Is this understanding correct?

Regards

Bhavesh

Former Member
0 Kudos

Dear Bhavesh,

Yes, you are right. The  three system of sender correspond to one interface.The mode: SOAP->RFC.

Hubery

bhavesh_kantilal
Active Contributor
0 Kudos

If you want to get the IP Address of the system that is triggering the call to PI, then this is pretty straight forward.

- In your SOAP Sender Adapter Select the Set Adapter Specific Attributes,

- Now your ASMA Parameters in the runtime will contain a parameter called SndrClientAddr under namespace http://sap.com/xi/XI/System/SOAP. This contains the IP Address of the calling system.

My Sender SOAP Adapter


Corresponding IP Address in the Dynamic Configuration


Local System IP Address as seen from my Command Prompt Matching what you see in PI




Former Member
0 Kudos

Dear Bhavesh,

The solution is OK, but tab "SndrClientAddr " is not existing when I enable the ASMA. Please point out. Thank you for your support.

Many thanks & best regards,

Hubery

anupam_ghosh2
Active Contributor
0 Kudos

Hi Hubery,

                     You can try this UDF


public static String getIPAddress(String url) throws Exception

{

  InetAddress address = InetAddress.getByName(new URL(url).getHost());

  url=address.getHostAddress();

  return url;

}

output of the code for following input

http://www.yahoo.com, IP address=106.10.139.246

http://www.google.com, IP address=216.58.221.36

include these import statement

import java.net.InetAddress;

import java.net.URL;

Regards

Anupam

Former Member
0 Kudos

Dear Anupam,

Thank you for your response. I forget to explain one point. In fact, There are 3 third-party system(OA,SEI and NSTC) to call the one PI interface. the website is different. I get the IP address according to the sender system(OA, SEI and NSTC), and handle different business. The sender system is random. There is no interface field to identify the website or IP address.

Hubery

anupam_ghosh2
Active Contributor
0 Kudos

What is the sender side adapter you are planning to use?

Regards

Anupam

Former Member
0 Kudos

SOAP adapter.

PI version: PI 7.11

anupam_ghosh2
Active Contributor
0 Kudos

To obtain the IP address, the UDF needs some input. Is there any information in SOAP request which can help PI to identity the sender IP?

Regards

Anupam

Former Member
0 Kudos

Dear Anupam,

In fact , the interface is to query the salary according to the department number. The all of three system need to send the department number to query the salary. As you know, the salary is high security. But the three system can query all salary. So we want to control it via IP address. The interface is done. The receiver adapter is RFC.

Please kindly give some advice. How to achieve it.

Hubery

bhavesh_kantilal
Active Contributor
0 Kudos

In addition to the detailed response I have provided to get the IP Address of the calling system, if all you would like to make sure if that only the calls from these 3 systems are allowed to call these service, you may use Access Control List of your Integrated Configuration.

What this means is, in your ICO, you can assign a User in the Assigned Users tab and then only these users will be allowed to access this Interface.

Eg: My ICO has user kantilalb assigned to it. When I trigger this ICO now for any other user (bhaveshk) I would get en error.