You are not logged in.
Pages: 1
Hi,
I create custom server
TMyRest = class(TRestServerFullMemory)
and register service
aServer.ServiceRegister(InvoiceService, [TypeInfo(IInvoiceService)],'1');
but in serivce methods self.server (TRestServer) is nil!
Last edited by anouri (2024-08-21 09:11:13)
Offline
unit Service.Invoice ;
TInvoiceService = class(TInjectableObjectRest, IInvoiceService)
public
constructor Create; overload;
function GetInvoiceList(const DateFr,DateTo: string): RawJson;
function TInvoiceService.GetInvoiceList(const DateFr,DateTo: string): RawJson;
begin
-- self.server is nil here
end;
constructor TInvoiceService.Create;
begin
inherited Create;
end;
Last edited by anouri (2024-08-21 10:05:04)
Offline
I can't find anything wrong. Any suggestions?
Offline
I guess because you created your own sicShared instance with your own TInvoiceService.Create without setting the property.
Auto-fill of the Server property is only if the framework make it.
If you make wrong initialization, it is... working wrong.
My guess is that you should call CreateWithResolverAndRest() as constructor, with the proper parameters, or just don't create your instance, but let the framework do it as sicShared, by providing a class and not an instance.
Online
I can't find anything wrong. Any suggestions?
Can you try this:
aServer.ServiceRegister(TInvoiceService, [TypeInfo(IInvoiceService)], '1'); // <---- replacing InvoiceService with TInvoiceService
JD
Last edited by JD (2024-08-21 15:19:38)
Offline
[dcc32 Error] View.Server.pas(109): E2250 There is no overloaded version of 'ServiceRegister' that can be called with these arguments
Offline
Thank you so much. this one worked:
aServer.ServiceRegister(TInvoiceService, [TypeInfo(IInvoiceService)], sicShared, '1');
Last edited by anouri (2024-08-22 08:22:28)
Offline
Pages: 1