WELCOME Abdennour : Software engineer

May 17, 2012

5. REST: Understanding the architectural style



 1.What is REST?
2. Resources
3. Representations
4.Advantages & Disadvantages : REST:
5.WADL
6. Tools & Plateforms: 








 1.What is REST?


REST is an architectural style which is based on web-standards and the HTTP protocol.
REST was first described by Roy Fielding in 2000.

Be Careful: REST is not a format Neither a protocol Neither standard .

Difference between REST & RESTfull:


-REST is the Web Service.
            it is also called: DOA (DATA.OA) aet ROA (Ressources.OA)
-RESTfull: is the application that respects the architecture ROA.




What's REST?

WS-Rest
       1.is Stateless
       2.Minimise system resources, but no session state.
-Resources  are uniquely identified by URIs.


REST request:
   1) Resources: -identified by URI.
               Exple: http://localhost:8080/insatdb/books
   2) Methods: Methods To manipulate the identifier:

       The HTTP standards methods which are typical used in REST are PUT, GET, POST, DELETE.
  • GET defines a reading access of the resource without side-effects. The resource is never changed via a GET request, e.g. the request has no side effects (idempotent).
  • PUT creates a new resource, must also be idempotent.
  • DELETE removes the resources. The operations are idempotent, they can get repeated without leading to different results.
  • POST updates an existing resource or creates a new resource.                                                        

   3) Representation of data transferred between server & client:
         => Example: XML, JSON, CSV, HTML ......


-The client is responsible for the state of resource.






2. Resources

-A resource can have multiple URIs.
      Example: Resource as: Books, Person
      Example: URI: http://localhost:8080/insatdb/books
            

-A resource may undergo(subir) four basic operations designated by CRUD (Create, Retrieve, Update, Delete)
 =>Create by the POST method
=> Retrieve by GET
=>Update = PUT-method
 =>Delete the DELETE method




3. Representations
   1)




Example Json format: Example XML format:


GET https://www.googleapis.com/urlshortener/v1/url?shortUrl=http://goo.gl/fbsS GET http://localhost:8080/librarycontentrestwebservice/contentbooks/string



{
"kind": "urlshortener#url",
"id": "http://goo.gl/fbsS",
"longUrl": "http://www.google.com/",
"status": "OK"
}


<?xml version="1.0"?>

<details>

Ce livre est une introduction sur la vie

</details>







NOTE: -Poster plugin available for Firefox for HTTP request issuing

Clear Difference: SOAP vs REST, 
             SOAPit sends an envelope,
              Rest is sent in an URI


4.Advantages & Disadvantages : REST:




SOA REST
Avantages
 Standardized
# Interoperability
# Security (WS-Security)


 Ease of implementation
# Readability by humans
# Scalability
# Relies on the principles of the Web
# Multiple Views

Disavantages
Performance (SOAP envelope additional)
# Complexity, heaviness

Security restricted by the use of HTTP methods
- call resource only

Extended Web services (SOAP)
5.WADL: 
WDAL:Web Application Description Language)
=> is an XML description language for RESTful services.
=> Describe Service For elements of type:
      Resource, method, parameter, Request, Response
=> Example: http://localhost:8088/librarycontentrestwebservice/application.wadl


<?xml version="1.0"?>
<application>

<doc jersey:generatedBy="Jersey: 1.4 09/11/2010 10:30 PM" />

<resources base="http://localhost:8088/librarycontentrestwebservice/" >

<resource path="/contentbooks" >

<resource path="uribuilder2" >

  <method id="createURIBooks" name="POST" >
         <request>
                 <representation mediaType="application/xml" />
     </request>

     <response>

                 <representation mediaType="*/*" />
     </response>
   </method>
</resource>

<resource path="uribuilder1" >

    <method id="createBooksFromURI" name="POST" >
       <request>
            <representation mediaType="application/xml" />
      </request>
     <response>

           <representation mediaType="*/*" />
      </response>
     </method>
</resource>
...
</resource>
</resources>

</application>


6. Tools & Plateforms: 
Tools Plateforms
CURL
PSTER(Firefox)
SoapUI
-Jax-Rs(Jersy)
.NET
.PHP
Python


Reference : 

No comments:

Post a Comment