Services Frequently Asked Questions


Do Remoting SDK servers require any registration on the computer where they run?

Not at all. The Remoting SDK servers work immediately without the need for you to register anything. For instance, you can just copy an Remoting ISAPI server on a web server and point to it from a client and it will work right away.


How can I call service methods in the service application itself?

In the simplest case you can call service method via something like:

new MyServiceClass().ServiceMethod();

But note, that this approach will not work if service method called uses Session or if service perform some initialization actions on activation (for example Data Abstract DataService acquires connection).

In this case it is better to implement methods like AcquireLocalService and ReleaseLocalService to instantiate and release the service objects:

RemObjects.SDK.Server.Service AcquireLocalService(Guid sessionId, String serviceName)
{
     RemObjects.SDK.Server.IClassFactory lServiceFactory = 
RemObjects.SDK.Server.ServiceManager.GetService(serviceName);

     RemObjects.SDK.Server.Service lResult = 
          Activator.CreateInstance(lServiceFactory.ServiceClass) as RemObjects.SDK.Server.Service;

     if (lResult is RemObjects.SDK.Server.IActivatableService)
        (lResult as RemObjects.SDK.Server.IActivatableService).Activate(sessionId);

     return lResult;
}

and

void ReleaseLocalService(Guid sessionId, RemObjects.SDK.Server.Service service)
{
     if (service is RemObjects.SDK.Server.IActivatableService)
        (service as RemObjects.SDK.Server.IActivatableService).Deactivate(sessionId);

     if (service is IDisposable)
        (service as IDisposable).Dispose();
}

Note, that for Data Abstract (.NET) LocalDataAdapter and LinqLocalDataAdapter components are available, which were designed to work with data within the same tier and can be used for local data requests.


How can I install multiple instances of the same service app?

Passing unique ServiceName and DisplayName parameters to ROStartService allows you to have an exe installed multiple times as a service.

For example, code similar to the following could be placed in the .dpr file:

var
  ServiceName: string;
  I: Integer;

begin
  ServiceName := '';
  for I := 1 to ParamCount - 1 do
  begin
    if ParamStr(I) = '/name' then
      ServiceName := ParamStr(I+1);
  end;
  if ServiceName = '' then
    ServiceName := 'MyROServer';

  if ROStartService(ServiceName, ServiceName) then ....

You will also need to ensure that the different services don't fight over resources (log files, TCP sockets, etc) since they'll be on the same machine.

It would be a good idea to use a configuration file per-instance to set those kinds of things at runtime so they can be changed easily.