Calling an XData service within the XData server Application

Let's say I have 2 services in my XData App: Service1 and Service2.

What is the best way to call a Service1 method from a method in Service2?

Hi. Inside the same binary? I guess creating it directly

var
  Service1: IService1;
begin
  Service1 := TService1.Create;
  (...)
1 Like

That's what I was thinking, but I wondered if that was the best way given that it is mapped into the XData environment to ensure that you get the correct object manager and session data.

1 Like

I would use In-Process Server.

https://doc.tmssoftware.com/biz/sparkle/guide/server.html#in-process-server

I believe context initialization can be an issue with calling just tservice.create how those atrributes will be injected to called service? Let us know the results.

But may be "TXDataOperationContext.Current" correcly initialized since both services will be in the same thread and you are going to call direcly the methods of the service. So that you can go for TService.Create

My recommendation was only for using xdata client methods to connect into the same server.

3 Likes

There is no correct answer. You want to delegate processing of Service1 to Service2? Or just use Service2 as an "internal" code?

Your Service2 might be doing low-level processing of the request/response. Is that accepted? So there is no correct answer.

1 Like