Send a credencial (string) at every execution to server


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).


You can send it in HTTP header.


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

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

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.