Accessing a service from Desktop App

I have a Service defined as

  IGARegisterService = interface(IInvokable)
    function Hello: String;

From a WebCore app I can access this service with

lRetval := await(TXDataClientResponse, WebClient.RawInvokeAsync('IGARegisterService.Hello', []));

WebClient is a TXDataWebClient linked to a TXDataWebConnection that uses the url

However in a VCL desktop application I have

  Client: TXDataClient;
  Retval: string;
   Client := TXDataClient.Create;
    Client.Uri := '';

      Retval := Client.Service<IGARegisterService>.Hello;
      MessageDlg(Retval, mtInformation, [mbOK], 0);
      on e: exception do
         MessageDlg(e.Message, mtError, [mbOK], 0);

But this raises the exception:

Project GATools.exe raised exception class EXDataInterfaceServiceNotFound with message 'Interface "IGARegisterService" not registered as a service contract.'.

Obviously I'm missing something somewhere.

Any ideas? Thanks.

Since your interface is tagged to model Biz.Sphinx, you should create the TXDataClient for that model:

   Client := TXDataClient.Create(TXDataAureliusModel.Get('Biz.Sphinx');

But Biz.Sphinx is an internal model used by TMS Sphinx, so I simply recommend that you remove the Model attribute from your interface, or simply use a different model.


I have it marked as Biz.Sphinx as I was having issues when I had it unmarked or marked as a different model.

What kind of issues? Note that when updating the database structure, you can pass several model names so the database will be updated accordingly to hold tables for all the provided models.

If I remove the service from Biz.Sphinx then I can't access it through the url that is used to access Sphinx.

If I add another XData server to the server app with a different URL then I can access the service, but then I get

Project GASphinx.exe raised exception class EXDataMissingConnection with message 'Database connection not avaiable. Check if the connection pool is properly configured.'.

Then records I am adding/updating are in the Biz.Sphinx model (extended user class and an organisation/company class).

Correct, you need another XData server.

That simply means you should set the Pool property of the TXDataServer component, if you want to use databases.

But fine, if you are extending Sphinx and all this is related to Sphinx, it's no problem you use the model Biz.Sphinx. But then, as I said, create the TXDataClient using that model.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.