IP Adress in service implementation

Hi everybody,

I just tested the XDataSwagger Demos, and I need to know if in service implementation of a method (let's say Add method) is there any way to get Headers of the call and the IP Address that did the request.

function TArithmeticService.Add(A, B: Double): Double;
var ip: string;
begin
ip := '??'; // how to get the ip address of this call?
Result := A + B;
end;

Thanks,
Mihai

Hi there,

Yes, you can use TXDataOperationContext to do that (unit XData.Server.Module)

IP := TXDataOperationContext.Current.Request.RemoteIp;

TXDataOperationContext.Current.Request has other useful information about the request you may be interested in

HTH,

1 Like

Thanks a lot, it works .

Mihai

1 Like

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.