Posts

Showing posts with the label REST

How to Consume JSON from RESTful Web Service and Convert to Java Object - Spring RestTemplate Example

So far, I have not written much about REST and RESTful web service barring some interview questions e.g. REST vs SOAP , which is thankfully very much appreciated by my readers and some general suggestions about best books to learn REST in past, but today I am going to write something about RESTTemplate class from Spring MVC framework. Like its predecessors JdbcTemplate and JmsTemplate, the RestTemplate is another useful utility class which allows you to interact with RESTful web services from a Java application built using Spring framework. It's a feature rich and supports almost all REST methods e.g. GET, POST, HEAD, PUT or DELETE, though we'll only use the GET method in this article to consume a RESTful Web Service and convert the JSON response to Java objects. It's one of the basic but interesting examples, given you will often find scenarios to consume a RESTful web service from Java program. Read more �

Top 5 Books to learn REST and RESTful WebServices for Java Programmers

The REST has now become the standard way to develop web services. It's no more SOAP, who used to rule the world in last two decade. The SOAP and XML went very well together in past decade but it seems now REST and JSON have overtaken then and doing even better. Since Java is one of the most popular languages to develop backend services, there is a lot of demand for Java developers who knows web services and can implement and expose existing SOAP-based services into REST style, light-weight web services. This is an excellent opportunity for intermediate and experienced Java developers to learn a more job-oriented skill to keep themselves marketable and many Java developer has already started learning REST and RESTful web services in Java. Read more �

Difference between JAX-RS, Restlet, Jersey, RESTEasy, and Apache CXF Frameworks

The JAX-RS is a Java specification request (JSR 311 & JSR 339) which standardize development and deployment of RESTful web services using Java and JEE technologies. It provides API in Java Programming language to create web services according to the REST (Representational State Transfer) architectural pattern. Both Restlet and Jersey are two of the most popular implementation of JAX-RS used for developing RESTful web services in Java ecosystem but there are a couple of other implementation also exist e.g. Apache Wink, Apache CXF, and JBoss RESTEasy. In this article, I'll introduce with these RESTful web services framework in Java world. It's not a very detailed post about strength and weakness of each of the framework but will just give you enough to understand them in detail later. Read more �

Difference between PUT and POST in REST WebService in Java

If you remember REST WebServices uses HTTP methods to map CRUD (create, retrieve, update, delete) operations to HTTP requests. Even though both PUT and POST methods can be used to perform create and update operation in REST WebServices, Idempotency is the main difference between PUT and POST. Similar to the GET request , PUT request is also idempotent in HTTP, which means it will produce the same results if executed once more multiple times. Another practical difference PUT and POST method in the context of REST WebService are that POST is often used to create a new entity , and PUT is often used to update an existing entity. If you replace an existing entity using PUT than you should be aware that if only a subset of data elements is passed then the rest will be replaced by empty or null. Read more �

Restlet HelloWorld Example in Java and Eclipse

The Restlet is one of the first open source frameworks to create and deploy RESTful web service in Java. After the release of JAX-RS (Java API for RESTful Web Services) JSR - 317, Restlet also supports JAX-RS annotation and provides a consistent way to create both RESTful Server and Client. HelloWorld program is the traditional way to start with a new technology and continuing to the tradition, we'll write our first Restlet program as HelloWorld. Since Restlet can be used to create on both client and server side, we'll first expose a resource as RESTful web service using Restlet server and then consumer the same RESTful web service by creating a RESTful client. I'll use Maven and Eclipse to create this RESTlet HelloWorld example , if you are not familiar with Maven, it's a build automation tool like ANT for Java projects but also provides dependency management i.e. you don't need to download Restlet JAR manually, Maven will do it for you. To learn more about Maven...

What are Idempotent and Safe methods of HTTP and REST

In order to efficiently work with REST and RESTful web service , good knowledge of HTTP is really helpful. Even though REST seems easy, designing a uniform and consistent RESTful API is a tough job . One of the tricky tasks is choosing right the HTTP method for right job e.g. when to use PUT vs POST. Once you know the meaning and purpose of different HTTP methods , it helps to choose the right method for the right job. You can divide HTTP methods into two main categories safe and idempotent . Safe methods are HTTP methods that do not modify the resource e.g. a GET request is safe because it doesn't modify the resource you are requesting e.g. data of a Book. Another safe HTTP method is HEAD , which doesn't change the resource representation on the Server, but all other HTTP methods e.g. POST , PUT , or DELETE are non-safe. Read more �