Jump to content
new_x

REST Web Service

Recommended Posts

I am trying to learn to write a Delphi REST Web Service program (both the server and the client side). Currently my platform is Delphi 11 Community Edition supporting Internet Direct (Indy) 10.6.20. I searched through the Internet have not found sample codes or explanations. All I found is some videos using DataSnap project but In delphi 11 I could not Find File->New->Other->Data Snap. The only option is “Soap Server Application”.

 

If my current version of Delphi does not support REST, Could you then provide SOAP based (server and client) source code and explanation.

Since I am newbie, could anyone share source code and explanations. Thanks in advance

Share this post


Link to post

You should check out https://github.com/danieleteti/delphimvcframework.

 

What's DelphiMVCFramework

DMVCFramework is a very popular Delphi framework which provides an easy to use, scalable, flexible RESTful, JSON-RPC and ActiveRecord framework for Delphi developers. DMVCFramework is the most popular Delphi project on GitHub and compiles for Windows (32 and 64bit) and Linux (64bit). DMVCFramework services can be compiled as console application, Windows Service, Linux daemon, Apache module (Windows and Linux) and IIS ISAPI (Windows).

DMVCFramework works with Delphi 11 Alexandria, Delphi 10.4 Sydney, Delphi 10.3 Rio, Delphi 10.2 Tokyo, Delphi 10.1 Berlin, Delphi 10 Seattle.

Share this post


Link to post

Thank you for kind reply. Just to explain further. In fact I am required to develop a web service to put data into learning platform Moodle.  The data (student ID, number etc.) should be read in GUI (edit boxes) or from a postgresql db and must be inserted into Moodle platform. I will look into DMVCFramework . thank you

Share this post


Link to post

I am not familiar with Moodle, but I'd probably just roll my own. Take an Indy Http server, handle GET, PUT, POST requests, done. You're in full control. I never had the need for any of these 3rd party frameworks (I'm sure they're great, though).

  • Like 1

Share this post


Link to post

...and don't forget the built in Delphi Rest debugger tool (under the tools menu). Can be handy for checking what you should be sending...

Share this post


Link to post

DataSnap is not available in the Community Edition. There are many alternatives. Two were mentioned above. Another one that I like is from TMS Software called XData; it's not free but they have a trial version available. mORMot is another one to check out: https://github.com/synopse/mORMot 

 

I'm guessing that your Moodle thing is a separate back-end service that you're supposed to access via your self-made service. This is a very common scenario. Imagine that you want to have a web (client) app that saves photos somewhere. The front-end is kept simple, and it sends requests to your back-end where you could build an entire database that manages all of the photos yourself. A simpler approach would be to use something like Dropbox or Google Files (?) instead. Or even Google's FireBase. This would simplify your service a lot by letting it talk to the remote file service via its own API. It doesn't matter what it's implemented in -- the one you've been told to use is in Moodle, but so what? It's the API you're mainly interested in.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×