brian71us
(brian71us)
February 27, 2017, 7:57pm
1
Hello,
I’ve got the following code in my application:
Channel := TROIndyHTTPChannel.Create(nil);
Channel.TargetUrl := 'http://' + Host + ':' + IntToStr(Port) + '/bin/';
BinMsg := TROBinMessage.Create;
Service := TRORemoteService.Create(nil);
Service.Channel := Channel;
Service.Message := BinMsg;
PrintService := (Service as IPrintService);
The server exposes multiple services, so is it possible to cast the Service to the appropriate services?
PrintService := (Service as IPrintService);
DataService := (Service as IDataService);
And what is the difference between this and what is shown below?
Channel := TROIndyHTTPChannel.Create(nil);
Channel.TargetUrl := 'http://' + Host + ':' + IntToStr(Port) + '/bin/';
BinMsg := TROBinMessage.Create;
PrintService := CoPrintService.Create(BinMsg, Channel);
DataService := CoDataService.Create(BinMsg, Channel);
Thanks!
EvgenyK
(Evgeny Karpov)
February 28, 2017, 9:49am
2
both pieces of code are equal only when RemoteService.ServiceName
is empty
second one will be executed a bit faster because RemoteService shouldn’t detect correspondent proxy class and create it.
also, you can simplify your code to
sUrl := 'http://' + Host + ':' + IntToStr(Port) + '/bin/';
PrintService := CoPrintService.Create(sUrl);
DataService := CoDataService.Create(sUrl);
in this case, proxy will use TROIndyHTTPChannel
and TROBinMessage
Hi
Could someone elaborate on this? I am using TRODynamicRequest and I am not sure of how to hook it in this scenario.
EvgenyK
(Evgeny Karpov)
July 5, 2018, 8:49am
4
assign MethodName
and call RefreshParams
. after this, you can assign values to parameters.
Do I correctly understood what you need?
Hi EvgenyK
So, I am not figuring out how to hook TRoDynamicRequest in the code you provided. I am currently using this code to hook everything together:
Url := 'http://' + Host + ':' + IntToStr(Porta) + '/bin/';
FCanal := TROIndyHTTPChannel.Create(nil);
Fcanal.TargetUrl := Url;
Fmsg := TROBinMessage.Create;
FServico := TRoRemoteService.Create(nil);
FServico.ServiceName := ServiceName;
FServico.Channel := FCanal;
FServico.Message := FMsg;
FRequest := TRoDynamicRequest.Create(nil);
FRequest.RemoteService := FServico;
FRequest.MethodName := methodName;
FRequest.RefreshParams();
Is there a simple way to to that?
EvgenyK
(Evgeny Karpov)
July 6, 2018, 12:39pm
6
DynamicRequest
requires TRORemoteService
so you can’t simplify your code.
w/o DynamicRequest
, you could do direct call like
sUrl := 'http://' + Host + ':' + IntToStr(Port) + '/bin/';
CoMyService.Create(sUrl).mymethod;
wuping
(wuping)
May 29, 2019, 11:17pm
7
Does TRODynamicRequest support out/var parameter?