You can easily invoke service operations from a Delphi application using the TXDataClient class. Even though XData implements service operations using standards HTTP and JSON, which allows you to easily invoke service operations using HTTP from any client or platform, the TXDataClient makes it even easier by providing strong typing and direct method calls that in turn perform the HTTP requests under the hood.
Another advantage is that you don't need to deal with marshaling parameters or even create client-side proxy classes. The same service interface you defined for the server can be used in the client. You can share the units containing the service interfaces between client and server and avoid code duplication.
To invoke service operations, you just need to:
1. Retrieve an interface using Service<I> method
2. Call methods from the interface.
Here is an example of invoking the method Sum of interface IMyService, declaring in the topic "defining service interface":
// Instantiate TXDataClient
Client := TXDataClient.Create;
// Set server Uri
Client.Uri := 'http://server:2001/tms/xdata';
// Retrieve IMyService inteface
MyService := Client.Service<IMyService>;
// call inteface methods
SumResult := MyService.Sum(5, 10);
Note that the client won't destroy any object passed as parameters, and will only destroy entities created by it (that were returned from the server), but no regular objects (like TList<T> or TStream). See "Memory Management" topic for detailed information.