RESTFul Web Services The Easy Way. What is REST? Representational State Transfer Maps your CRUD...
-
Upload
timothy-harrington -
Category
Documents
-
view
218 -
download
1
Transcript of RESTFul Web Services The Easy Way. What is REST? Representational State Transfer Maps your CRUD...
![Page 1: RESTFul Web Services The Easy Way. What is REST? Representational State Transfer Maps your CRUD actions to HTTP verbs ActionVerb CreatePOST RetrieveGET.](https://reader036.fdocuments.us/reader036/viewer/2022082512/5513c9615503466f748b4949/html5/thumbnails/1.jpg)
RESTFul Web ServicesThe Easy Way
![Page 2: RESTFul Web Services The Easy Way. What is REST? Representational State Transfer Maps your CRUD actions to HTTP verbs ActionVerb CreatePOST RetrieveGET.](https://reader036.fdocuments.us/reader036/viewer/2022082512/5513c9615503466f748b4949/html5/thumbnails/2.jpg)
What is REST?
•Representational State Transfer•Maps your CRUD actions to HTTP verbs
Action Verb
Create POST
Retrieve GET
Update PUT
Delete DELETE
![Page 3: RESTFul Web Services The Easy Way. What is REST? Representational State Transfer Maps your CRUD actions to HTTP verbs ActionVerb CreatePOST RetrieveGET.](https://reader036.fdocuments.us/reader036/viewer/2022082512/5513c9615503466f748b4949/html5/thumbnails/3.jpg)
Why REST?
•Simple, both conceptually and programmatically
•Simpler and cleaner than SOAP
![Page 4: RESTFul Web Services The Easy Way. What is REST? Representational State Transfer Maps your CRUD actions to HTTP verbs ActionVerb CreatePOST RetrieveGET.](https://reader036.fdocuments.us/reader036/viewer/2022082512/5513c9615503466f748b4949/html5/thumbnails/4.jpg)
SOAP ExamplePOST /InStock HTTP/1.1 Host: www.example.org Content-Type: application/soap+xml; charset=utf-8 Content-Length: nnn
<?xml version="1.0"?> <soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"> <soap:Body xmlns:m="http://www.example.org/stock">
<m:GetStockPrice> <m:StockName>IBM</m:StockName>
</m:GetStockPrice> </soap:Body>
</soap:Envelope>
![Page 5: RESTFul Web Services The Easy Way. What is REST? Representational State Transfer Maps your CRUD actions to HTTP verbs ActionVerb CreatePOST RetrieveGET.](https://reader036.fdocuments.us/reader036/viewer/2022082512/5513c9615503466f748b4949/html5/thumbnails/5.jpg)
REST ExampleGET /stock/IBM HTTP/1.1 Host: www.example.org Accept: application/xml
![Page 6: RESTFul Web Services The Easy Way. What is REST? Representational State Transfer Maps your CRUD actions to HTTP verbs ActionVerb CreatePOST RetrieveGET.](https://reader036.fdocuments.us/reader036/viewer/2022082512/5513c9615503466f748b4949/html5/thumbnails/6.jpg)
SOAP Example 2POST /InStock HTTP/1.1 Host: www.example.org Content-Type: application/soap+xml; charset=utf-8 Content-Length: nnn
<?xml version="1.0"?> <soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-
envelope" soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"> <soap:Body xmlns:m="http://www.example.org/stock">
<m:BuyStock> <m:StockName>IBM</m:StockName> <m:Quantity>50</m:Quantity>
</m:BuyStock> </soap:Body>
</soap:Envelope>
![Page 7: RESTFul Web Services The Easy Way. What is REST? Representational State Transfer Maps your CRUD actions to HTTP verbs ActionVerb CreatePOST RetrieveGET.](https://reader036.fdocuments.us/reader036/viewer/2022082512/5513c9615503466f748b4949/html5/thumbnails/7.jpg)
REST Example 2POST /order HTTP/1.1 Host: www.example.org Content-Type: application/xml; charset=utf-8
<?xml version="1.0"?> <order>
<StockName>IBM</StockName><Quantity>50</Quantity>
</order>
![Page 8: RESTFul Web Services The Easy Way. What is REST? Representational State Transfer Maps your CRUD actions to HTTP verbs ActionVerb CreatePOST RetrieveGET.](https://reader036.fdocuments.us/reader036/viewer/2022082512/5513c9615503466f748b4949/html5/thumbnails/8.jpg)
Single Resource Summary
•Create▫POST /resourceName
•Retrieve▫GET /resourceName/resourceId
•Update▫PUT /resourceName/resourceId
•Delete▫DELETE /resourceName/resourceId
![Page 9: RESTFul Web Services The Easy Way. What is REST? Representational State Transfer Maps your CRUD actions to HTTP verbs ActionVerb CreatePOST RetrieveGET.](https://reader036.fdocuments.us/reader036/viewer/2022082512/5513c9615503466f748b4949/html5/thumbnails/9.jpg)
Making it Easy: JSR 311
•JAX-RS: The Java API for RESTful Web Services
•No XML Configuration!▫Simple annotations to quickly put together
some rest based web services.•Can do automatic serialization (both XML
and JSON + many others)
![Page 10: RESTFul Web Services The Easy Way. What is REST? Representational State Transfer Maps your CRUD actions to HTTP verbs ActionVerb CreatePOST RetrieveGET.](https://reader036.fdocuments.us/reader036/viewer/2022082512/5513c9615503466f748b4949/html5/thumbnails/10.jpg)
Example Application w/ Jersey
![Page 11: RESTFul Web Services The Easy Way. What is REST? Representational State Transfer Maps your CRUD actions to HTTP verbs ActionVerb CreatePOST RetrieveGET.](https://reader036.fdocuments.us/reader036/viewer/2022082512/5513c9615503466f748b4949/html5/thumbnails/11.jpg)
Some REST/Jersey/JAXB Gotchas•No real security standard for REST.
▫Mostly DIY solutions•Hibernate dependencies
▫Use cg-lib-nodeps
![Page 12: RESTFul Web Services The Easy Way. What is REST? Representational State Transfer Maps your CRUD actions to HTTP verbs ActionVerb CreatePOST RetrieveGET.](https://reader036.fdocuments.us/reader036/viewer/2022082512/5513c9615503466f748b4949/html5/thumbnails/12.jpg)
Questions?