You are not logged in.
I'm trying to accomplish the following setup:
I have a "generic" server process "LCSRestServer" running, implementing a very simple interface with a TSQLRestServerDB instance. This server uses its own very simple TLCSServerModel = class(TSQLModel).
type
ILCS = interface(IInvokable)
['{31969E17-758B-4077-B0E8-77B81B082715}']
{1 open the database as specified in the connectionstring, return if this was succesfull
- aConnectionstring contains all info needed to connect using <protocol>://server/name syntax
- if aCreate is true than create the database if it doent exist
}
function OpenDatabase(aConnectionString: RawUTF8; var URI: RawUTF8; aCreate: boolean = false): boolean;
end;
The client process can now tell the server to open the specified database, making it available to the client. This database is implementing a different TSQLModel ("TLCSModel"), the RestServer must be implementing a different interface "ILCSDatabase"
The implementation of the OpenDatabase method being:
function TLCSServer.OpenDatabase(aConnectionString: RawUTF8; var URI: RawUTF8; aCreate: boolean = false): boolean;
var
...
begin
//Determine database type and protocol
lConProp := CreateConnectionProperties(aConnectionString);
if lConProp <> nil then
begin
//Create separate TSQLRestSeverDB object for this database
lModel := TLCSModel.Create(URI);
lModel.RegisterVirtualTables(lConProp);
lRestServerDB := TLCSRestDB.Create(lModel, UTF8ToString(URI) + '.db3');
lRestServerDB.CreateMissingTables;
lRestServerDB.ServiceRegister(TLCSDatabase , [TypeInfo(ILCSDatabase)], sicShared);
//Register the new restServer with the http server of the main server process
LCSRestServer.RegisterDatabase(lRestServerDB);
Result := true;
end;
end;
Somehow i'm not getting this whole setup working... The above method does work, but when i try to run the following method on the client side, it says it can't find LCSDatabase as a service on the server ...
FModel := TLCSModel.Create(cURI);
FClient := TSQLite3HttpClient.Create('localhost','888',FModel);
FClient.ServiceRegister([TypeInfo(ILCS)],sicShared);
FClient.Services[cURI].Get(FLcsInterface);
FLcsInterface.OpenDatabase(cNewFolder, lDBUri, True);
FClient.ServiceRegister([TypeInfo(ILCSDatabase)],sicShared); // <<==Error: "LCSDatabase" interface or REST routing not supported by server
FClient.Services[lDBUri].Get(lDbInterface);
What am i doing wrong?
Offline
You mean running THttpApiServer.AddUrlAuthorize() ?
Done that
Offline
But when creating the TSQLRestServer i have set HandleUserauthentication to false ...
Offline
User authentication is mandatory for using services.
You have to set HandleUserauthentication = true, otherwise you won't be able to use remotely services.
This is mandatory for security reasons.
You can use hardcoded username and password for the communication, in your client code, if you do not need to handle user grant access at your application level.
Offline
aHa!
Offline