Blog

All Blog Posts  |  Next Post  |  Previous Post

TMS XData is coming

Bookmarks: 

Monday, August 26, 2013

A new framework named TMS XData is cooking in the TMS labs. It's hard to define what a framework is with a few words, especially if such framework is modular and many pieces of it can be used separately. Nevertheless, using a very broad definition I could say that TMS XData is a framework that allows you to provide and consume application data through Rest services. But maybe instead trying to define it, I should give you a small sample.

XData can be strongly integrated with TMS Aurelius, our ORM framework. I have posted some articles here about Aurelius and some very simple samples, so in case you still don't know about it, you can check how to getting started or, related to this article, how to create simple associations with it.

Now let's build a very simple XData server that serves Aurelius objects:

program SimpleXDataServer;

{$APPTYPE CONSOLE}

uses
  Aurelius.Drivers.Interfaces,
  Aurelius.Engine.ObjectManager,
  XData.Http.Server,
  XData.Aurelius.EntityServer,
  Utils,
  Customer;

procedure CreateCustomer(const CustomerName, CountryName: string);
var
  Manager: TObjectManager;
  Customer: TCustomer;
  Country: TCountry;
begin
  Manager := TObjectManager.Create(SQLiteConnection);
  Country := TCountry.Create;
  Country.Name := CountryName;
  Customer := TCustomer.Create;
  Customer.Name := CustomerName;
  Customer.Country := Country;
  Manager.Save(Customer);
  Manager.Free;
end;

var
  Conn: IDBConnection;
  Server: THttpServer;
begin
  ReportMemoryLeaksOnShutdown := true;
  Conn := SQLiteConnection;
  BuildDatabase(Conn);
  CreateCustomer('Paul', 'United States');
  CreateCustomer('Jonas', 'Germany');
  CreateCustomer('Hiroto', 'Japan');
  CreateCustomer('Jian', 'China');
  CreateCustomer('Sergei', 'Russia');

  Server := THttpServer.Create;
  Server.RegisterHandler(
    TAureliusEntityServer.Create(
      'http://aurelius:2001/tms/xdata', SQLiteConnection));
  Server.Start;

  WriteLn('Running Simple XData Server');
  ReadLn;
  Server.Free;
  DestroyDatabase(Conn);
end.
The code above uses the classes TCustomer and TCountry defined in the blog post "Associations (foreign key)". They are simple classes and I'm not showing them again here for simplicity. Also, be aware that try..finally blocks were removed also to make code cleaner.

The above application is a regular TMS Aurelius application, that connects to a database, creates needed tables and insert some data. The different part is the one that creates a THttpServer instance and register a request handler under the address "/tms/xdata". What happens here is that Aurelius objects are now being provided through a very well defined Rest API.

XData is inspired by the OData protocol. Even though it's not compatible with it, it uses similar concepts, and of course is REST/JSON based which makes it very compatible with other clients and platforms. It also makes everything automatic for XData: your TCustomer objects, for example, are available at the address "http://aurelius:2001/tms/xdata/TCustomer" (Naming can be configured as well).

Another interesting thing is how this data is easily accessible from everywhere. As an example, here is the full source code of a .NET C# console application that connects to such server and retrieves the customer objects from it, using Linq: <snip> And here is the output generated by this C# application.


More info coming soon!

Update: upon its release, we decided to build TMS XData with its own JSON format - OData was heavily XML-based at that time. So TMS XData is no longer (has never been, since it's official 1.0 version) OData compatible.

Wagner Landgraf


Bookmarks: 

This blog post has received 14 comments.


1. Wednesday, August 28, 2013 at 4:46:17 AM

Hi Wagner

very great info.

When will available the product be tested (also in beta)?

I''m testing Aurelius and I am really impressed by the power of the framework!

Best Regards

Claudio

Piffer Claudio


2. Wednesday, August 28, 2013 at 4:47:20 AM

Please contact us by email and we''ll provide you with a beta.

Bruno Fierens


3. Thursday, August 29, 2013 at 5:27:40 AM

Will this be sth like DataSnap? What is the advantage of your frame work? Thanks,

Tang Haizhou


4. Thursday, August 29, 2013 at 7:37:12 AM

There is some intersection with DataSnap, but one doesn''t cover all features of the other so far. XData is more object-oriented and makes use of Aurelius to make everything to be more automatic - you have the url''s, the data format. For transfer data objects from ORM between client and server, it''s very straightforward

Wagner Landgraf


5. Thursday, August 29, 2013 at 7:37:24 AM

Looks very promising indeed. But just like Tang I wonder how this compares to datasnap, where you also have good rest support.

Can you tell a bit more about the supported REST methods and how they are supported?

Birger Jansen


6. Thursday, August 29, 2013 at 9:09:23 AM

Initially, the main feature is strong Aurelius integration. The objective is take advantage of existing info that an Aurelius mapping provides, and makes everything to be available in an easy, automatic way. If you take the example in this blog post, for example, it''s just a few lines of code, but with that you already have the url resources defined. You can access the customer list at address http://aurelius:2001/tms/xdata/TCustomer, you can have a specific customer at http://aurelius:2001/tms/xdata/TCustomer(2), you can retrieve the country associated with a customer at address http://aurelius:2001/tms/xdata/TCustomer(2)/FCountry, you can send PUT, POST, DELETE methods to those address to create, edit, update customers, countries, etc.. There is already a standard query format you can pass to the first mentioned address to filter the customers, for example. And the output format is already provided in a standard way, Xml or Json, also taking advantage of lazy loading. So those are examples of Rest methods already available with that few lines of code

Wagner Landgraf


7. Thursday, August 29, 2013 at 9:34:59 AM

Yes ! Way to go !

Carre Stephane


8. Tuesday, September 3, 2013 at 2:52:06 AM

This is good news indeed! Aurelius is a great product. XData will make it even greater.

Day Kevin


9. Tuesday, September 3, 2013 at 4:27:26 AM

Will XData also solve the issue / problem I descibed here: http://www.tmssoftware.com/site/forum/forum_posts.asp?TID=2939&title=jsOn-issues ?
If possible, can I also test a beta version? I am working on a pet project that could benefit from this. I would be happy to provide you with my feedback!

van der Sluis Joost


10. Tuesday, September 3, 2013 at 10:34:32 AM

I have answered your technical question in forum, doesn''t look like you would need XData just for that. About the beta, please send us an e-mail from the address you want to receive information about the beta, I will reply you to that address.

Wagner Landgraf


11. Friday, December 6, 2013 at 5:53:39 AM

Any news? When will XData be ready for us?

ZippoSLO


12. Friday, December 6, 2013 at 12:56:01 PM

XData is still under work. It should probably be released by the end of January.

Wagner Landgraf


13. Friday, March 21, 2014 at 12:53:05 PM

Any news? When will XData be ready for us?

Hugo


14. Saturday, March 22, 2014 at 7:22:50 PM

Unfortunately we had some delays, indeed. We decided to split XData in more modular frameworks, and the first one will be released next week. Then we will manage to release the others in the following weeks.

Wagner Landgraf




Add a new comment

You will receive a confirmation mail with a link to validate your comment, please use a valid email address.
All fields are required.



All Blog Posts  |  Next Post  |  Previous Post