5

I have a webservice implemented using RemObjects over Delphi XE and I want to know the ip address of the clients petitions. My service inherits from TRORemoteDataModule and I haven't found any method or object to do that.

Any suggestion? Thanks

Note: I think that the information that I need is returning in the method self.transport.GetTransportObject() but it returns a TObject and I don't know how to extract this information

2 Answers2

4

This is how I get it from a SuperChannel:

procedure TMyInterface.RORemoteDataModuleGetDispatchInfo(const aTransport: IROTransport; const aMessage: IROMessage);
var
  tcpinfo: IROTCPTransport; 
  Session: TCustomSession;
  szClientIP : String;
begin
  Session := TCustomSession(Self.Session);
  if Supports(aTransport, IROTCPTransport, tcpinfo) then
  begin
    szClientIP := tcpinfo.ClientAddress;
    if (not Session.ShownTCP) or (Session.TCPAddress <> szClientIP) then
    begin
      Session.TCPAddress := szClientIP;
      Session.Report(leInformation, 'TCP address ' + szClientIP); 
      Session.ShownTCP := True; 
    end; 
  end 
  else 
  begin 
    Session.Report(leInformation, 'TCP address not available');
  end;
end;

The specifics of what you do with it are up to you, but you have to get it as it is set up, and store it in the session object if you want to pick it up later. I implemented a custom session to hold the client Ip so that I could get it any time in further calls.

mj2008
  • 6,647
  • 2
  • 38
  • 56
  • It works. I only needed the Supports function, for load the tcpInfo object. Thanks a lot –  Apr 23 '12 at 09:24
  • At the moment, TRORemoteDataModule implements a Transport property, so you don't have to write such a code in the OnGetDispatchInfo. You can just execute it from a server function. – gabr Apr 21 '15 at 20:49
0

here it is how to do it

http://wiki.remobjects.com/wiki/Server_FAQs_%28RemObjects_SDK%29#How_can_I_get_IP_address_of_the_remote_client.3F

RBA
  • 12,337
  • 16
  • 79
  • 126
  • I found it but it's unuseful. I don't have IServerChannelInfo. Maybe in delphi is slightly different –  Apr 23 '12 at 08:26
  • unfortunately I do not have RemObjects installed, so I'm trying to help based on the poor documentation provided by RemObjects. http://wiki.remobjects.com/wiki/Server_FAQs_%28RemObjects_SDK%29#How_can_I_log_details_.28IP_address.2C_method_name.2C_parameters.2C_duration.2C_etc..29_of_every_call_made_to_a_server.3F – RBA Apr 23 '12 at 08:44