DataSnap.FireDACJSONReflect REST Server Client Sample
This sample demonstrates the use of the Data.FireDACJSONReflect unit to pass FireDAC datasets and deltas between a DataSnap client and a DataSnap REST server.
Location
You can find the FireDACJSONReflect sample project at:
- Start | Programs | Embarcadero RAD Studio Sydney | Samples and then navigate to Object Pascal\DataSnap\FireDACJSONReflect.
- Subversion Repository for Delphi: https://github.com/Embarcadero/RADStudio10.3Demos/tree/master/Object%20Pascal/DataSnap/FireDACJSONReflect
Contents
Description
This sample demonstrates how to build a multi-tier application with DataSnap framework.
The server and the client communicate using the HTTP protocol to exchange JSON data through a REST interface.
Server
- The server is a DataSnap REST web application that accesses data from an InterBase database.
- The sample adds FireDAC components to the Server Module to connect to an Interbase database.
- The sample adds new methods in ServerMethodsUnit1 to retrieve JSON data from the underlying InterBase EMPLOYEE sample database, and to expose these server methods to the client.
Client
- The client is a multi-device application that includes a DataSnap REST Client Module.
- The client calls the server methods to retrieve the data from the server.
- The client also calls a method to apply changes to the database storing and passing data through TFDMemTable components.
How to Use the Sample
- Navigate to Start | Programs | Embarcadero RAD Studio Sydney | Samples and go to Object Pascal\DataSnap\FireDACJSONReflect.
- Select DepartmentsClientProject.dproj and DepartmentsServerProject.dproj.
- Open the client and the server.
Server Project
- Select DepartmentServerProject.exe on the Project Manager.
- Run the application by clicking Run > Run Without Debugging in the IDE or by pressing Shift+Ctrl+F9.
- The Server's interface opens. Click Start to start the server and then minimize it.
Client Project
- Select DepartamentClientProject.exe on the Project Manager.
- Run the application by clicking Run > Run in the IDE or by pressing F9.
- The Client application enables you to test the server method classes.
- Click Get Departments to display a list of department names and numbers.
- Click on a department to see department details and employees.
- Modify a value in the department details and/or employee and then click Apply Updates to send changes to the server.
Files
The files used by this sample are:
Server Files
File | Contains |
---|---|
WebModuleUnit1.pas/dfm |
The DataSnap Server Components. |
ServerMethodsUnit1.pas/dfm |
The Server module with the FireDAC components. |
DepartmentsServerProject.dproj |
The project itself. |
DepartmentsServerFormU.pas/dfm |
The Server form. |
Client Files
File | Contains |
---|---|
DepartmentsClientProject.dproj |
The project itself. |
DepartmentClientFormU.pas/fmx |
The main form that is the user interface for the DataSnap Client application. |
ClientModuleUnit2.pas/dfm |
The module with the TDSRestConnection component. |
ClientClassesUnit2.pas |
The client classes from the server generated with the TDSRestConnection component. |
Uses
- Datasnap.DSServer.TDSServer
- Datasnap.DSServer.TDSServerClass
- DSHTTPWebBroker.TDSHTTPWebDispatcher
- FireDAC.Comp.Client.TFDConnection
- FireDAC.Comp.Client.TFDQuery
- FireDAC.Phys.IB.TFDPhysIBDriverLink
- FireDAC.Comp.UI.TFDGUIxWaitCursor
- FireDAC.Comp.Client.TFDMemTable
- Datasnap.DSClientRest.TDSRestConnection