Design RESTful Services for Oracle JET: Part 1

by Kenneth Lange  

When you start getting serious about Oracle JET, one of the first questions that pop up is how do you design the RESTful services that your Oracle JET application needs to call?

This is the first post in a mini-series that will try to answer that question.

So what are RESTful Services, anyway?

RESTful means REpresentational State Transfer. It sounds pretty complicated, but in reality it’s a piece of cake!

It means that a server has a “resource” and a client can request a “representation” of this resource. For example, if the resource is an article stored in a database then its representation could be a copy of all its attributes (i.e. headline, author, body, publish date, etc.) wrapped in JSON format.

The idea is that the client shouldn’t care about the server’s internal implementation of the resource. The server might store the article in an Oracle Database, or even a flat file, it doesn’t matter to the client. All the client cares about is the representation that it gets from the server.

When the client has received the representation, it can update the representation (for example, change the headline), and send its updated representation back to the server. The server can then update its internal resource with data from the updated representation.

The interaction between the client and server is stateless, which means that no client session information is stored on the server. Each client request must contain all the information needed for the server to fulfill the request. Needless to say, this does wonders for scalability!

To me the attractive thing about the RESTful architecture is its simplicity. You normally just need to glance at a RESTful service to get a pretty good idea about how to use it, and the clean interface between the client and server helps decouple the application and reduce complexity.

Why not just use SOAP??

Nothing (except common sense!) stops us from calling SOAP services in Oracle JET. JQuery is an integrated part of the toolkit, and you can use this low-level library to call SOAP web services (see here for an example of a JQuery SOAP client).

But you really don’t want to do this. This is not only because SOAP is a pretty verbose format that has been rejected by rest of the JavaScript community. Nor because as Martin Fowler writes that XML’s distinction between elements and attributes makes no sense for data structures.

The reason you should use RESTful services is that you can then use Oracle JET’s Model and Collection APIs to handle the interaction, which will boost your productivity (and work happiness!) because you don’t have to write a lot of boring, boilerplate code.

That’s it for the first post in this mini-series!

Share this post:

Facebook Twitter LinkedIn Email



Subscribe to my blog

Just enter your email below and press the button:


Related Posts: