Tuesday, 8 December 2015

Difference between Rest and Soap based web service..............








WADL - Web Application Description Language for JAX-RS Rest Web Service
   
1. Rest is not standard while soap is standard


2. Rest is light and faster compare to Soap

3. Rest Supports only http protocol while SOAP supports other protocol like
    JMS,SMTP etc.

4. XSD is used in Soap & Rest both

5.  Rest uses protocol level security (SSL) only while SOAP support both protocol level security and message level security(SOAP-WS).

6. Soap supports WS Atomic transaction while rest is not

7. SOAP is message orientated & Rest is resource orientated

8. SOAP supports encoding while Rest is not.

9. REST can generate difference types of response like XML/JSON/JPEG etc. while SOAP response is only in XML Soap format.

10. Rest can be accessed from browser java script code while Soap is not...

      Example

$(document).ready(function() {
  $("#nextFruit").click(function(){
  var imagePath=$("#imageContainer").attr("src");
  var pathTokens=imagePath.split("/");
  var imageId=pathTokens[pathTokens.length-1];
  ///////////////////////////////////////////
  $.ajax( { url:contextPath+'/rest/v1/fruit/ajax/'+imageId,
  //  dataType: "xml",
  accept: "Application/json",
  success:function(data) {
              //var xmlString = (new XMLSerializer()).serializeToString(data);
               $("#imageContainer").attr("src","rest/v1/fruit/image/"+data['fid']);
               $("#fname").html(data['fruitName']);
               $("#fcolor").html(data['color']);
               $("#fprice").html(data['price']);
               $("#ftaste").html(data['taste']);
             },
             error:function(){
              alert("+__@_ERROR__##");
             }
          });   
 
    //end of ajax call
     ///////////////////////////////////////
    //this should come from ajax
    
  });
   }); 


11. Rest is based on JAX-RS while SOAP is based JAX-WS







No comments:

Post a Comment