
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" , 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
or JSON files.2.) Browser-based
or Mobile app Integration.Since JSON is Light weight (provides inbuilt support with Javascript & Browser) so uses less bandwidth.3.) Less Preferred where Security 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.)
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.
____________________________________________________
I will use SOAP when : -
1.) When my Data is of the form
.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
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.)
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.
Thanks for your article ....this is one of the very confusing question with no clear answer....but I am very much clear now
You're Welcome Mr kumar. Happy to help you.