Saturday, 26 September 2015

Deleting a project from Chrome Rest client

Background

Making REST API calls from some client to test out stuff is normal for any programmer. Programmers use various REST clients. I have seen most of the programmer use either
  1.  Postman or
  2.  Advanced REST client.
I prefer the  later one. No particular reasons but I just started with Advanced REST client so continuing with the same.




So in Advanced REST client you can save your REST calls in a PROJECT. A project can have multiple REST calls associated with it. This is where I was stuck. I created multiple projects with some dups and wanted to clean it up. Advanced REST client allows you to delete the API calls from the project but not the project itself. So naturally you looks for workarounds and today I will show you one.

Solution is quite simple. You delete it yourself from the application database. All you need to know is where and how. We will see that now.


 Deleting a project from Chrome Rest client

I have created a dummy project named GREETINGS and have added a dummy API call called ADD_CUST. Deleting API call is easy. Just click the delete icon just besides the API selector on the top.




As you must have notices we do not have option to delete project itself. Lets see how we can do that by deleting project from App database. Follow below steps

  1. Right click 
  2. Inspect Element 
  3. Go to resources Tab
  4. Select restClient DB
  5. view projects table

You will see all the projects listed there.



Notice the ID of the project here. it's 10. We will use it later.  For now lets just see how can we run SQLs here. For this click on the database -restClient in this case. You should see a prompt. You can enter your SQL queries here.

Run simple query :
  • select * from projects;
You should see list of all available projects.



 Finally lets see how we can delete a project. Execute following query.

  • delete from projects where id=10;
Your project should get deleted from the DB. You can verify it by running select again.



Now simply refresh the page and you should see your project gone!

 

SOAP vs REST Web Services

Background

        It's been around couple of months since this topic has confused me a lot. Every time I have discussion about webservices I always try to figure out difference between SOAP based web service (JAX-WS Java API) and REST based web service (JAX-RS) web service. When the picture is finally clear let me put it down for others.

Biggest point to note about SOAP and REST is that they cannot be compared!  Yes you read it right you cannot compare both. You can only do comparison of things that are different aspects of same thing and these are not. 

SOAP (Simple Object Access Protocol) is a protocol which uses XML to communicate data. Like any other protocol it has it's own rules. REST (Representational State transfer) on the other hand is an architecture (repeating architecture) meaning a way to design APIs. 

Given that we will see each in a bit more detail so that it gives us a clear picture of REST and SOAP based web service.

W3C defines a web service as
 "A software system designed to support interoperable machine-to-machine interaction over a network."

SOAP based web services

  • SOAP stands for Simple Object access protocol.
  • As the name suggests this is a protocol. 
  • SOAP uses service interfaces and named operations to expose the APIS.
  • SOAP requires more bandwidth that REST requests.
  • You can only transfer (send/receive) XML payload from SOAP based webservices.
  • Java API for this is JAX-WS
  • SOAP has Web Services Description Language (WSDL) which describes how webservice will work and lets you get a reference to it.
  • SOAP based messages have strict specifications to follow for implementation.
  • SOAP defines it's own security standards WS-security..


REST based web services

  • REST stands for Representational state transfer.
  • This is an architectural approach.
  • REST uses URLs and method types (HTTP verbs like GET, POST, PUT etc) to expose APIs.
  • REST requires less bandwidth that SOAP based requests.
  • In REST you can send and receive any type of payload (Json, XML, HTML).
  • Java API for this is JAX-RS
  • REST does not have strict restrictions like SOAP.
  • For security REST calls rely in underlying protocol like HTTPS.


Generic Notes

  1. HTTP verbs used by REST
    1. GET
    2. OPTION
    3. POST
    4. PUT
    5. PATCH
    6. DELETE
  2. Careful with HTTP POST verb. It is not safe and not idempotent.So You cannot just resend.
  3. In REST based requests , response may be cached. Server may return ETag header when accessed. Client send this tag on subsequent request to access resource. If resource is not changed server will return 304 (not modified).




Major differences between GET and POST

 

Related Links 


 
t> UA-39527780-1 back to top