When to use REST & When to use SOAP ?

Most of the sfdc beginners came across this question "When should I use REST & When to use SOAP API" suspecting-emoticon-design-30573285, but not all of us end up getting the appropriate answer.Many of us start writing REST API's because they're widely used.

I'll provide you some practical Scenarios for using REST & SOAP API's.As a sfdc Developer :

I will use REST when : -

1.) When my Data is in the form of XML xml    or JSON   json-filetype-document-file-filetype-document-file-512files.

 

2.) Browser-based 08-ios7-style-safari-iconor Mobile app mobile-app-icon_66196Integration.Since JSON is Light weight (provides inbuilt support with Javascript & Browser) so uses less bandwidth.

 

 

3.) Less Preferred where Security  business_office-46-512  is the biggest Concern. eg- Banking Apps. Because REST API only provides Http SSL Encryption .

 

 

4.) When Custom Error handling is to done.Since there's no built in Error handling Feature in REST.

 

5.)

Screenshot from 2017-04-03 19:07:06

 

 

6.) REST services are Cacheable.

This feature is very useful, Say if you want to share with your friend a Mobile details that you are planning to purchase, what you need to do is just share the link which is a REST call. 31163A0400000578-3442108-image-a-27_1455189872679

 

 

Screenshot from 2017-04-03 18:23:03

 

 

________________________________________________________________________________________________

I will use SOAP when : -

1.) When my Data is of the form   xml.

 

2.) Used in Real-time client applications that update small numbers of records at a time.Avoid it in case of low Bandwidths as XML (Heavy-weight).

 

3.) Preferred where Security   Security_Approved is the biggest Concern. Example - Banking Apps & industry standard softwares like TIBCO, IBM . Because SOAP API  provides both Http SSL Encryption & WS Security Encryption.

 

4.) When built in Error handling is required.If there is a problem with SOAP request sent.SOAP response will contain error information of it.

 

5.) Screenshot from 2017-04-03 19:07:45

 

6.) SOAP services are not cacheable as there is a need to explicitly form a SOAP request so that server can understand.

Say if you like to purchase any mobile and want to share details of that mobile with your friend in this case you need to explicitly tell your friend to go to xyz url and then press this button etc. which is painful.

 

GwRYd

 

Responses

  1. Thanks for your article ....this is one of the very confusing question with no clear answer....but I am very much clear now

Comments are closed.

Popular Salesforce Blogs