Send a credencial (string) at every execution to server

Hi

We need to send (at every request) a string (like a user credencial in a string format) to server .
My channel is created like that:

...
  path := 'bin';

  Url := 'http://' + Host + ':' + IntToStr(Porta) + '/' + path + '/';

  FCanal := TROIndyHTTPChannel.Create(nil);
  Fcanal.TargetUrl := Url;
  Fmsg := TROBinMessage.Create;
  FServico := TRoRemoteService.Create(nil);
  FServico.Channel := FCanal;
  FServico.Message := FMsg;

  .... use FServico to make a server call

I didn’t find any place in order to set a string (and, at server, read it).

Hi,

You can send it in HTTP header.

ROIndyHTTPChannel1.IndyClient.Request.CustomHeaders.AddValue('myheader','myvalue');

on server-side you can read it in Service.OnGetDispatchInfo event:

procedure TNewProjectService.RORemoteDataModuleGetDispatchInfo(
  const aTransport: IROTransport; const aMessage: IROMessage);
var
  s: string;
begin
  s := (aTransport as IROHTTPTransport).Headers['myheader'];
end;

if you like to pass user credential and process it before execution of service method, you can use HTTPServer.OnCustomResponseEvent event.

check for more info in Using OnCustomResponseEvent in a ROSDK Server snippet.