Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Best for REST server?



Permlink Replies: 22 - Last Post: Jul 10, 2014 12:22 AM Last Post By: Robert Triest
Matthew Jones

Posts: 337
Registered: 1/25/98
Best for REST server?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 1, 2014 5:32 AM
What technology that works with Delphi XE2 would be best for making a
REST server that supports https?

I have done a lot of work with the RemObjects SDK, and it is very nice
for accessing from Delphi clients and Javascript in the browser. I see
that it can be cooerced into doing REST, but it would be good to have a
look at all the options.

FWIW, I expect that the calls will be of the form:

server.com/api/dataset/{id}/section/ref/{id}?param=whatever

where the dataset (not a literal database) is selected and a sub-select
then occurs on that.

Scalability would be nice, though not critical.

Matthew
Robert Triest

Posts: 687
Registered: 3/24/05
Re: Best for REST server?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 1, 2014 5:51 AM   in response to: Matthew Jones in response to: Matthew Jones
https://www.embarcadero.com/kr/rad-in-action/delphi-labs
Episode 07 - DataSnap - REST Web App Tutorial
Matthew Jones

Posts: 337
Registered: 1/25/98
Re: Best for REST server?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 1, 2014 6:10 AM   in response to: Robert Triest in response to: Robert Triest
Robert Triest wrote:

https://www.embarcadero.com/kr/rad-in-action/delphi-labs
Episode 07 - DataSnap - REST Web App Tutorial

Thanks - that does look like a viable start. I'd not thought of the
ISAPI option either, which would help (I presume) with scaling. I
thought DataSnap was a database access thing, but this doesn't seem to
have such link which is fine. The Actions looks both a handy mechanism
and not big enough to fit my needs, but that probably means that there
are events I could hook anyway.

A good starting point - thanks. Anyone know of other options?

Matthew
Matthew Jones

Posts: 337
Registered: 1/25/98
Re: Best for REST server?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 1, 2014 6:26 AM   in response to: Matthew Jones in response to: Matthew Jones
Matthew Jones wrote:

A good starting point - thanks. Anyone know of other options?

I've found https://plus.google.com/+PaulThornton/posts/h5bz3b2nbWh
which I'm not entirely sure does what I want yet (got to read the
source!) and also
http://stackoverflow.com/questions/14645022/can-remobjects-sdk-parameter
s-be-passed-via-the-uri but that's a little too DIY and I could do that
with the RO stuff today if I wanted (I have already hacked the server
for other projects). I actually quite like the idea of having a hacked
server as then I can use the standard RO for some things, and REST for
others. But if there is a clean solution, I'm open.

Matthew
Robert Triest

Posts: 687
Registered: 3/24/05
Re: Best for REST server?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 1, 2014 7:05 AM   in response to: Matthew Jones in response to: Matthew Jones
Most of the DataSnap projects I did were ISAPI/CGI or "Webbroker"
Normally the need is to receive the post params from the URI
and pass them to your server methods (Delphi procedures and functions)
and return the result webpage. DataSnap will create a (https) webserver and
the source for adding your (existing !) Delphi objects and functions. That is just like
creating a ISAPI DLL or CGI exec. (but the whole ready to start framework is created for you)
In these Delphi functions you can of course use all the database access of Delphi on the
server database if you want.

The cool thing is that DataSnap is also creating your javascript
source (proxies) for calling these Delphi functions from the client browser.
On the client side you can use these JavaScript .js file to execute the
server functions. (HTML-button-javascript-function-DataSnap Server-Delphi function)
Abdullah Kauchali

Posts: 6
Registered: 4/3/02
Re: Best for REST server?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 8, 2014 9:30 AM   in response to: Robert Triest in response to: Robert Triest
The cool thing is that DataSnap is also creating your javascript
source (proxies) for calling these Delphi functions from the client browser.
On the client side you can use these JavaScript .js file to execute the
server functions. (HTML-button-javascript-function-DataSnap Server-Delphi function)

Robert,

That does indeed sound cool. I didn't know this. Is it possible for you to post sample .js files that DataSnap produces (I am stuck in XE2 land).

regards

AK
Robert Triest

Posts: 687
Registered: 3/24/05
Re: Best for REST server?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 10, 2014 12:22 AM   in response to: Abdullah Kauchali in response to: Abdullah Kauchali
There are some standard Datasnap system' js files that handle the JavaScript.
(ServerFunctionExecutor, ServerFunctions, json-min, CallbackFramework)

Under is the generated code ServerFunctions.js. This a function that is standard as
an example when you create a new DataSnap project. This function you can call
from your HTML file JavaScript section.

this.ReverseString = function(Value) {
    var returnObject = this.executor.executeMethod('ReverseString', "GET", [Value], arguments[1], true, arguments[2], arguments[3]);
    if (arguments[1] == null) {
      if (returnObject != null && returnObject.result != null && isArray(returnObject.result)) {
        var resultArray = returnObject.result;
        var resultObject = new Object();
        resultObject.Value = Value;
        resultObject.result = resultArray[0];
        return resultObject;
      }
      return returnObject;
    }
  };

This is the original Delphi code.
Everytime you add a new Delphi function the ServerFunctions.js file
is extended with the function when you compile your datasnap project.

function ReverseString(Value: string): string;
 
implementation
 
function TServerMethods1.ReverseString(Value: string): string;
begin
  Result := StrUtils.ReverseString(Value);
end;
Eli Mapstead

Posts: 5
Registered: 4/11/02
Re: Best for REST server?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 2, 2014 9:59 AM   in response to: Matthew Jones in response to: Matthew Jones
Matthew Jones wrote:
A good starting point - thanks. Anyone know of other options?

Just use straight LAMP or LEMP if you really need it to scale and it is just a REST endpoint.
Matthew Jones

Posts: 337
Registered: 1/25/98
Re: Best for REST server?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 2, 2014 10:11 AM   in response to: Eli Mapstead in response to: Eli Mapstead
Eli Mapstead wrote:

LAMP

Using Delphi code?

Matthew
Eli M

Posts: 1,346
Registered: 11/9/13
Re: Best for REST server?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 3, 2014 7:52 PM   in response to: Matthew Jones in response to: Matthew Jones
No, PHP.
Kim Madsen

Posts: 362
Registered: 12/13/99
Re: Best for REST server?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 1, 2014 6:25 AM   in response to: Matthew Jones in response to: Matthew Jones
Den 7/1/2014 14:32, Matthew Jones skrev:
What technology that works with Delphi XE2 would be best for making a
REST server that supports https?

I have done a lot of work with the RemObjects SDK, and it is very nice
for accessing from Delphi clients and Javascript in the browser. I see
that it can be cooerced into doing REST, but it would be good to have a
look at all the options.

FWIW, I expect that the calls will be of the form:

server.com/api/dataset/{id}/section/ref/{id}?param=whatever

where the dataset (not a literal database) is selected and a sub-select
then occurs on that.

Scalability would be nice, though not critical.

Matthew

kbmMW contains extensive support for REST.
You can email me on kbm at components4developers dot com and Ill mail you a
sample REST web application server back, which includes:

- Sample jQuery AJAX call into the server
- Sample jQuery AJAx call with authentication/authorization
- Form post
- Simple object marshalling (kbmMW contains full support for marshalling
native Delphi object instances to and from XML and JSON)

Oh.... and ofcourse kbmMW is known to be high uptime, fast, flexible and
scalable.

best regards
Kim Madsen
C4D
Matthew Jones

Posts: 337
Registered: 1/25/98
Re: Best for REST server?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 1, 2014 6:53 AM   in response to: Kim Madsen in response to: Kim Madsen
Kim Madsen wrote:

kbmMW contains extensive support for REST.

Thanks, I've had a whizz around the site (that's a review thing, not
like the Bear Whizz Beer I hear is sold in the US!) and it makes me
think. I have to work out what I'm really going to do here. Am I
exposing a database (or rather, many databases), or am I wanting to
have something do the work for me in parsing the parameters and the
like?

Does kbmMW have any assistance for the latter?

Matthew
Kim Madsen

Posts: 362
Registered: 12/13/99
Re: Best for REST server?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 1, 2014 7:06 AM   in response to: Matthew Jones in response to: Matthew Jones
Den 7/1/2014 15:53, Matthew Jones skrev:
Kim Madsen wrote:

kbmMW contains extensive support for REST.

Thanks, I've had a whizz around the site (that's a review thing, not
like the Bear Whizz Beer I hear is sold in the US!) and it makes me
think. I have to work out what I'm really going to do here. Am I
exposing a database (or rather, many databases), or am I wanting to
have something do the work for me in parsing the parameters and the
like?

Does kbmMW have any assistance for the latter?

Matthew

Yes, absolutely!

Its a misunderstanding that kbmMW is database centric. Its not. If
anything, kbmMW is SOA (service oriented architecture) and RPC (remote
procedure call) oriented.

If one boils kbmMW's down to its core, it contains no DB related code
what so ever, but focus solely on serving requests with 0-n arguments
(and optional stream) and returning a response with an optional response
stream.

The db parts are optional and are based on that core.

The core is also what contains all sorts of features for handling HTTP
headers, JSON and XML documents, encryption, authorization, object
serialization/marshalling etc.

But all is optional, and do not link in to your application if not used.

kbmMW is actually a very capable and complete web server in its own, and
lets you fiddle with post/get/head etc. in the smallest detail if you
want to, while at the same time providing you all the tools needed to
make simple URL rewriting, HTTP template macro replacements etc.

And the cool (Im biased... but I personally think its cool ;)) is that
it gives you the option to separate your functionality away from the
chosen user access method, in such way that you can build web clients,
native mobile clients and think pc clients accessing the same server at
the same time, having the bulk of the code exactly the same.

However thats also an option, and you can choose to go right to the
metal and just code directly for web clients only.

As an example of the flexibility of kbmMW, I can mention the latest
release also supports hosting FastCGI servers. In other words you can
use kbmMW to host your preferred PHP/Perl/Ruby/Python based CMS system,
and plugin your own Delphi/c++ code as you see fit, all under the full
control of kbmMW.

best regards
Kim Madsen
C4D
Kim Madsen

Posts: 362
Registered: 12/13/99
Re: Best for REST server?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 1, 2014 7:10 AM   in response to: Kim Madsen in response to: Kim Madsen
think = thick :) And I cant even blame IOS/Android spellchecker for that
mistake ;)

best regards
Kin Madsen
C4D
Wagner Landgraf

Posts: 47
Registered: 9/10/07
Re: Best for REST server?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 1, 2014 8:22 AM   in response to: Matthew Jones in response to: Matthew Jones
"Matthew Jones" wrote in message news:683557 at forums dot embarcadero dot com...

What technology that works with Delphi XE2 would be best for making a
REST server that supports https?

I have done a lot of work with the RemObjects SDK, and it is very nice
for accessing from Delphi clients and Javascript in the browser. I see
that it can be cooerced into doing REST, but it would be good to have a
look at all the options.

FWIW, I expect that the calls will be of the form:

server.com/api/dataset/{id}/section/ref/{id}?param=whatever

where the dataset (not a literal database) is selected and a sub-select
then occurs on that.

Scalability would be nice, though not critical.

Matthew

TMS Software is creating a set of products for http/https-based servers. It
provides TMS Sparkle (http://www.tmssoftware.com/site/sparkle.asp), TMS
RemoteDB (http://www.tmssoftware.com/site/remotedb.asp) and the upcoming TMS
XData (http://www.tmssoftware.com/site/blog.asp?post=271). Yes,
unfortunately, TMS XData is delayed. But if you are really interested, send
us a private e-mail (through http://www.tmssoftware.com/site/support.asp)
and we can exchange extra info and I can provide you with a beta version.

Wagner R. Landgraf
TMS Software
Matthew Jones

Posts: 337
Registered: 1/25/98
Re: Best for REST server?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 1, 2014 8:29 AM   in response to: Wagner Landgraf in response to: Wagner Landgraf
Wagner Landgraf wrote:

TMS Software is creating a set of products for http/https-based
servers. It provides TMS Sparkle
(http://www.tmssoftware.com/site/sparkle.asp), TMS RemoteDB
(http://www.tmssoftware.com/site/remotedb.asp) and the upcoming TMS
XData (http://www.tmssoftware.com/site/blog.asp?post=271).

Thank you - I will review. The XData looks interesting.

Matthew
Arnaud BOUCHEZ

Posts: 143
Registered: 2/17/02
Re: Best for REST server?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 2, 2014 1:37 AM   in response to: Matthew Jones in response to: Matthew Jones
Take a look at http://mORMot.net

This is an open source high performance and full of features framework for building RESTful services.

It is driven by convention over configuration.

You can create remote ORM access and services.

It works from Delphi 6 up to XE6.

You can write firemonkey clients if needed, or Ajax clients.

It has built in security, high performance and huge documentation. It is highly maintained since years.
Matthew Jones

Posts: 337
Registered: 1/25/98
Re: Best for REST server?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 2, 2014 2:31 AM   in response to: Arnaud BOUCHEZ in response to: Arnaud BOUCHEZ
Arnaud BOUCHEZ wrote:

Take a look at http://mORMot.net

This is an open source high performance and full of features
framework for building RESTful services.

Thanks for that. It looks quite capable. The "ORM" part scares me a
little, but I know a .Net programmer who uses ORM and likes it. What I
see though is that he "suffers" when he has to create some new value,
where my Delphi "naive" code just manually gets a new value from the
JSON or whatever.

What the answers to my question have revealed is how much more thinking
I need to do to work out what I need. I started making the database
from the existing code (that is not database based) and realised how
much of the solution is "smart" and not just access to fields. REST may
be a useful thing for some purposes, but may not help the smart parts.

Thanks all for your input - I will come back to this once I've worked
out more thoughts.

Matthew
Arnaud BOUCHEZ

Posts: 143
Registered: 2/17/02
Re: Best for REST server?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 2, 2014 8:18 AM   in response to: Matthew Jones in response to: Matthew Jones
ORM is optional, and pretty easy to work with.

For concepts and patterns see http://blog.synopse.info/post/2014/04/18/Introducing-mORMot-s-architecture-and-design-principles and our 1.18 SAD pdf.
Zhihua Ye

Posts: 13
Registered: 8/26/13
Re: Best for REST server?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 9, 2014 10:36 PM   in response to: Matthew Jones in response to: Matthew Jones
mORMot is awesome! Arnaud is awesome!

Download and check the example code and that 1,000+ PDF manual, check how active the forum is (http://synopse.info/forum/), check how frequent Arnaud commits (http://synopse.info/fossil/timeline), and you'll see what I mean.

And don't forget to check this independent stability and speed tests: http://robertocschneiders.wordpress.com/2012/11/22/datasnap-analysis-based-on-speed-stability-tests/

Matthew Jones wrote:
Arnaud BOUCHEZ wrote:

Take a look at http://mORMot.net

This is an open source high performance and full of features
framework for building RESTful services.

Thanks for that. It looks quite capable. The "ORM" part scares me a
little, but I know a .Net programmer who uses ORM and likes it. What I
see though is that he "suffers" when he has to create some new value,
where my Delphi "naive" code just manually gets a new value from the
JSON or whatever.

What the answers to my question have revealed is how much more thinking
I need to do to work out what I need. I started making the database
from the existing code (that is not database based) and realised how
much of the solution is "smart" and not just access to fields. REST may
be a useful thing for some purposes, but may not help the smart parts.

Thanks all for your input - I will come back to this once I've worked
out more thoughts.

Matthew
christian.kaufm...
Re: Best for REST server?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 2, 2014 10:33 PM   in response to: Matthew Jones in response to: Matthew Jones
What technology that works with Delphi XE2 would be best for making a
REST server that supports https?

I use Indy HTTP server and superobjects for JSON. However for EWB I
write the JSON export myself because there the order of the fields
matter (hope this will be solved in 2.0).

For HTTPS I run an Apache Server and use ProxyPass to redirect
requests to my Delphi server running on a different port.

cu Christian
Daniele Teti

Posts: 2
Registered: 4/7/11
Re: Best for REST server?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 3, 2014 10:19 AM   in response to: christian.kaufm... in response to: christian.kaufm...
What technology that works with Delphi XE2 would be best for making a
REST server that supports https?

You can also try DelphiMVCFramework (I'm the main developer)

This is the project site
https://code.google.com/p/delphimvcframework/

It is simple (really simple), it is RMM Level 3, it is really RESTful (modeled from Java JAX-RS and Ruby Sinatra), support clustering using Redis, scripting using Lua.

Here's some features from the project page
RESTful (RMM Level 3) compliant
Can be used in load balanced environment using Redis
Fancy URL with parameter mappings
Specialied renders to generate text, html, JSON
Powerful mapper to map json to objects and datasets to objects
Can be packaged as stand alone server, apache module (XE6) and ISAPI dll
Integrated RESTClient
There is a sample for each functionlities
There is a complete set of trainings about it, but the samples are included in the project
Experimental support for IOCP?
Server side generated pages using eLua (Embedded Lua)
Specific trainings are available (ask me for a date and a place)
Messaging extension using STOMP (beta)
Community driven (Facebook group https://www.facebook.com/groups/delphimvcframework)
Simple and documented (right click "Save as...")
Completely unit tested

If you need help, there is the proper facebook group where ask
https://www.facebook.com/groups/delphimvcframework/

Edited by: Daniele Teti on Jul 3, 2014 10:24 AM
Matthew Jones

Posts: 337
Registered: 1/25/98
Re: Best for REST server? [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 4, 2014 2:44 AM   in response to: Daniele Teti in response to: Daniele Teti
Daniele Teti wrote:

You can also try DelphiMVCFramework (I'm the main developer)

Thanks!

Matthew
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02