Java Reference
In-Depth Information
XML could be represented as a YAML document, which is arguably more readable and definitely
more concise:
---
books:
- title: My First Book
authors:
- {Anton, Anonymous}
- title: Another Book
authors:
- {Anton, Anonymous}
- {Bruce, McAuthor}
However, every technology comes with advantages and disadvantages, and SOAP remains in wide
use, especially in enterprise environments that have a strong need for its versatility.
rest
This section looks at how REST—Representational State Transfer—works. REST is extremely
well suited for basic, ad hoc web services. In addition, as the standard is very tightly coupled
with HTTP, it has become the architecture of choice by “modern” web companies (think of
social networks, for example) to provide APIs with which third‐party developers can develop
applications. In fact, a shift is going on where developers can be seen first constructing a REST
API (API‐first development) and then building their own applications and websites around this
API.
One of the biggest differences between REST and SOAP is that SOAP is communication agnostic
(remember that SOAP messages can be transferred on top of HTTP or any other network proto-
col), whereas REST is tightly integrated with HTTP and “embraces” the protocol. In fact, a REST
request looks completely similar to a normal HTTP request:
GET /books/B101 HTTP/1.1
Host: www.example.com
This is a normal HTTP GET request for the URI /books/B101 sent to the host www.example.com .
The server can then respond with a formatted representation of the topic with ID B101. Other
HTTP request types—apart from GET —exist. In the previous discussion on SOAP, for example, the
SOAP request message was sent using a POST request type. GET and POST are the most commonly
used HTTP methods. In fact, your browser will typically execute GET requests to request an URL
and will perform POST requests to send web forms to the server. In the context of “RESTful” web
services, however, the following HTTP methods are used, which are typically requested on collec-
tion resources (with an URI such as http://www.example.com/books ) or specific resource elements
(such as http://www.example.com/books/B101 as shown previously):
GET : Retrieve a list of resources belonging to a collection, or a formatted representation of
information on a resource element.
 
Search WWH ::




Custom Search