#1 2022-05-10 08:59:02

shragam
Member
Registered: 2013-07-01
Posts: 24

What is the correct way to create API web server and how to start ?

I apologize if the question is not the most obvious, but I have no experience at all with this framework/server.

I'm using Delphi 11.1 and my application is win32 and SQL server with ADO.
I need to create an API web server to my application that will enable to get/update/delete data from a web browser.
I read about mORMot framework and want to try it instead of DataSnap WebBroker application.

I have some questions:
1. Can I stay with ADO (All my code and Data Module is With ADO components and most of the logic is in the DM) ?
2. How do I get started with mORMot to develop a small testing server?
3. Dose mORMot  is the correct solution ?

Thanks

Offline

#2 2022-05-10 09:07:37

dcoun
Member
From: Crete, Greece
Registered: 2020-02-18
Posts: 176

Re: What is the correct way to create API web server and how to start ?

1. I believe using ZEOS database connection will allow you to use ADO
2. Take a look in examples from Mormot1 and use Mormot2 to start learning. Read the documentation, search the forum and invest time. Start creating only an interface based API and do not expose the database bindings.
3. It has to do with what you want to do. It is a feature rich framework for API creation.

Offline

#3 2022-05-10 09:31:51

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 13,170
Website

Re: What is the correct way to create API web server and how to start ?

1. You can stay with ADO if you have already existing code, and want to publish them as interface-based services.
But be aware that ADO has poor performance, and you need to intialize the OLE layer in each thread. So the interface-based services could e.g. run in a dedicated thread (see the options).
So I would consider using our direct ODBC/OleDB access classes to MSSQL instead of ADO. Note that for MSSQL, Zeos has no real benefit in respect to our ODBC and OleDB direct layers.

2. Start with the FAQ of mORMot 1.
And for your case, https://tamingthemormot.wordpress.com/2 … databases/

3. Yes, mORMot is always correct, it even makes coffee and can be used go to Mars. wink
But to publish services using interfaces, it is just a nice tool.

Offline

#4 2022-05-10 09:44:36

shragam
Member
Registered: 2013-07-01
Posts: 24

Re: What is the correct way to create API web server and how to start ?

ab wrote:

1. You can stay with ADO if you have already existing code, and want to publish them as interface-based services.
But be aware that ADO has poor performance, and you need to intialize the OLE layer in each thread. So the interface-based services could e.g. run in a dedicated thread (see the options).
So I would consider using our direct ODBC/OleDB access classes to MSSQL instead of ADO. Note that for MSSQL, Zeos has no real benefit in respect to our ODBC and OleDB direct layers.

2. Start with the FAQ of mORMot 1.
And for your case, https://tamingthemormot.wordpress.com/2 … databases/

3. Yes, mORMot is always correct, it even makes coffee and can be used go to Mars. wink
But to publish services using interfaces, it is just a nice tool.

Thanks

1. Today I'm already working with ADO and thread , create an adoconnection in every thread. (I'm working against MSSQL server).
I need to continue working with my current win32 application and also support web access. 
2. I'll start reading .
3. Good to know it ?
4. I'll back back with more questions after reading?

Offline

#5 2022-05-12 10:08:59

shragam
Member
Registered: 2013-07-01
Posts: 24

Re: What is the correct way to create API web server and how to start ?

My application is win32 VCL and dbGo ADOConnection, ADODataset etc.
I read the FAQ in the last few days and checked out some examples. The truth is I got pretty lost.
I'm used to working with components and events of Adding / Saving / ADODataset events.
I could not see here how I can use all my code and the logic that exists in my existing system.
I just need to write the web server side for my application and use my current code. (Is it possible ?) 

1. Looks like everything needs to be rewritten and I can not use any of my existing code in the Data modules(all the logic and events in TADODataset)?
2. Are there objects/components here for managing everything related to working with the database in terms of the server side?
Any help/direction what to do ?

Thanks

Offline

#6 2022-05-12 12:27:27

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 13,170
Website

Re: What is the correct way to create API web server and how to start ?

1. Define your services as interfaces.
One interface per execution scope - not a single interface for all.

2. Then implement the interfaces as classes, calling the datamodules queries.
Note that ADO (and VCL) are not multi-threaded, so you should ensure the interface is run in the main thread.

You can of course start with a few methods, and see how it works for you.

Offline

#7 2022-05-12 12:36:22

shragam
Member
Registered: 2013-07-01
Posts: 24

Re: What is the correct way to create API web server and how to start ?

ab wrote:

1. Define your services as interfaces.
One interface per execution scope - not a single interface for all.

2. Then implement the interfaces as classes, calling the datamodules queries.
Note that ADO (and VCL) are not multi-threaded, so you should ensure the interface is run in the main thread.

You can of course start with a few methods, and see how it works for you.

1. I have no idea how to it. Never defined interface ?. How I can access to my ADODataset events?

On my customer card form for example, I have ADODataset_Custs that his events like BeforePost, AfterPost and so on call this to the same object on the Data Module  and there I handled the validation and other rules.
If the  rule is not ok, I raise an exception and handle it on the main form.   

2. I know it.

Hope I explained it ok, I'm newbie in all this subject.
Shraga

Offline

#8 2022-05-12 14:08:29

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 13,170
Website

Re: What is the correct way to create API web server and how to start ?

Ensure you read https://tamingthemormot.wordpress.com/2 … databases/
and the mORMot documentation about interfaces and services.

Offline

#9 2022-05-13 05:40:49

shragam
Member
Registered: 2013-07-01
Posts: 24

Re: What is the correct way to create API web server and how to start ?

ab wrote:

Ensure you read https://tamingthemormot.wordpress.com/2 … databases/
and the mORMot documentation about interfaces and services.

I'll read it again

Offline

Board footer

Powered by FluxBB