Have an amazing solution built in RAD Studio? Let us know. Looking for discounts? Visit our Special Offers page!
C++CodeDatabaseDelphiRAD Studio

Quickly And Easily Build A REST Based Notes App With RAD Server In Delphi And C++

EMS.NotesResource Sample is a server-client EMS demo.

It requires InterBase to be installed on the machine or to connect to a remote server. Make sure that the server is running before you run the sample. InterBase is used to store the information with the server connections. Use the RAD Server Console to display the statistics.

The first part consists of creating an EMS Package with a new ResourceName (Notes). Once you run the package, the resource is registered on the EMS server and can be accessed by a client application using REST.

The client needs a TEMSProvider to connect to the EMS Server and to retrieve the JSON data.

How to Use the Sample

Run the EMS Package

When you run the NotesResourcePackage project, the EMSDevServer starts automatically. If the configuration file is missing, a wizard launches.

  1. Navigate to the location given above and open:
    • Delphi: NotesResourcePackage.dpk
    • C++: NotesResourcePackageCpp.cbproj
  2. Press Shift+Ctrl+F9 or choose Run > Run Without Debugging.
  3. The EMS Development Server opens. If it is the first time you are using EMS on the machine, you need to run the configuration wizard in order to create the EMS server configuration file.
    1. When the Confirm dialog opens, click Yes.
    2. Leave all the parameters by default and go through the different windows by clicking Next.
    3. Click Finish to close the wizard.
    4. An Information window appears. Click OK.
  4. The server starts automatically. Minimize it.

Run the Client Application

The client expects the EMSDevServer to be running at localhost:8080. If you are running the server at a different address, modify the properties of the TEMSProvider component.

The Delphi supported platforms for this sample are: 32-bit, 64-bit Windows, and iOS Simulator.

  • To run the sample on iOS Simulator, change the URLHost property of the TEMSProvider component to the IP address from the machine you are launching the sample and running the server.Note: The TEMSProvider component is placed in the NotesClientModule unit.

The C++ Supported platforms for this sample are: 32-bit and 64-bit.

  1. On the Project Manager, right-click on ProjectGroup1.
  2. Click Add Existing Project….
  3. Navigate to:
    • Delphi: Start | Programs | Embarcadero RAD Studio Sydney | Samples\Object Pascal\DataBase\EMS\NotesResource\NotesClientProject.dproj.
    • C++: Start | Programs | Embarcadero RAD Studio Sydney | Samples\CPP\Database\EMS\NotesResource\NotesClientProjectCpp.cbproj.
  4. Press F9 or choose Run > Run.
  5. Insert a User name and Password and click Signup, or Login if you previously created an account.
  6. Click Add to add a new note.
  7. Write the note and click Save.

Implementation

EMS Package

The Resource Module has code to register a REST OverView API resource. The resource is called “Notes”. The resource defines a Get, GetItem, Post, PutItem, and DeleteItem method.

Once you run the package and have the EMS server running, as a test, you can invoke the GET method by using the browser http://localhost:8080/Notes.Note: An error message appears informing that you need to be logged in to access this information.

The NotesStorageU file defines the path of the notes.ini file where the created notes are saved.

Client Application

The client application has a TEMSProvider component. This component identifies the address of the RAD Server Engine (EMS Server) (http://localhost:8080).

The client application also has a TBackendEndPoint for each method. This component identifies the name of a resource (Notes), the method used, and the ResourceSuffix.

The information is managed with TJSONObject and TJSONArray.

You can find attached a link below with the original post:

http://docwiki.embarcadero.com/CodeExamples/Sydney/en/EMS.NotesResource_Sample

Dev Days of Summer 2-24

Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial   Upgrade Today

   Free Delphi Community Edition   Free C++Builder Community Edition

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

IN THE ARTICLES