The full form of REST is Representational State Transfer. It is based on client/server, stateless, cache able communication protocol and mostly works through the mechanism of HTTP protocol.
REST is primarily used for designing networked applications and is mostly famous because it helps to establish a connection between two applications using simple HTTP calls. The whole Internet world is based on HTTP and hence it will be not wrong to say that World Wide Web is completely REST based architecture.
These applications use HTTP request to post data and delete data so basically it uses HTTP for all type of create, read, update, delete operations.
It is preferred by most of people instead of using remote procedure calls and other Web services due to its lightweight nature. Although it is simple but it is loaded with features so it provides you all the functionality which you want to achieve using Web services.
Although lot of programming frameworks exist for REST but there are no standards as such to follow and hence you can develop your own REST framework with libraries available in most of the programming languages.
There are various types of mechanisms or frameworks used while building Web services and it becomes confusing for people to understand the true difference between all of these.
Web services are written to integrate two different applications on machines which make call to each other using different mechanisms and different frameworks. The basic starts with the remote procedure call which is basically a mechanism which provides you with the ability to execute methods remotely and is used by CORBA, Java, SOAP, REST etc. Few of these use binary data transfer and some are text based, and few of the text based are actually XML-based.
When the data which gets transferred between two applications is XML-based then it is known as XML RPC. Earlier only SOAP-based systems were part of Web services architecture but REST has also gained huge momentum.
In layman terms, the difference between SOAP and REST is that SOAP is an XML RPC web service while REST is not.
In terms of programming REST is a lightweight alternative to Web services and remote procedure calls. REST is platform-independent, language independent, based on HTTP and can easily be used through firewalls. It offers no inbuilt security mechanisms, encryption or session management etc. hence you need to add them manually by using tokens. You can use passwords spoken for security and secure sockets for encryption. If we talk of a good design in REST then you need to get rid of cookies. An efficient design system is fully independent and carries everything needed by server to complete the call within the request itself.
Since REST is HTTP-based so it becomes important to understand what the HTTP request is. In simple words when you open a website on your browser then everything you do on that website from starting generate HTTP requests that are sent to the server. It is the server which replies to your request to build the complete page which is rendered to you. The response from server is the combination of HTML code, images, some additional data etc. required to display the page properly. Every HTTP request consists of three parts request, header and main body.
If you will use any load testing tool like WAPT you will notice that the request begins either with get or post which is basically the method specification. There are lots of other methods as well but they are primarily used for special purposes and are not shown in regular user sessions generated by browsers.
POST as the name suggests is used to send the data to the server while GET is used to receive the response from a server. Both of these request may or may not contain parameters and are the most important part of any request as they deal with carrying dynamic data. For example if any web page requires authentication and if the same is accessed by multiple users then a same type of request is sent to the server but every request would contain different parameter values because every individual would have different combination of username and password.
Hence we can now understand that whenever we try to access a website or an online application through our computer than a request is sent to the server which contains various interesting information.
If you will do load testing with any application and would try to analyze the request you will find these following things present in that. The first one would be your IP address which can reveal a lot of things about you such as your location, your ISP or other whereabouts of you on the Internet etc.
It will also contain destination IP address, host, port and the protocol used. This information reveals which server you are trying to send the request to or to which server the request is being sent. As various websites can be hosted on the same server hence it becomes imperative to understand which website you are trying to access on that particular server.
URL of the document becomes an important part in these type of request and the correct URL is determined by a combination of various information. The HOST in the header and destination port number specifies the correct document to be retrieved.
You would have noticed lot of websites give you the data back as far as the browser and its version being used, operating system and its version and also some additional information in few cases. This data is retrieved from the user agent part of the header.
There are various other things you will notice in the result of such load testing like the connection control, cache control, authorization etc. Hence it can be easily said that the most important piece of information contained in the request is
- Yours or the proxy IP address.
- The document which you have requested.
- Browser being used.
- Source page if in case you clicked on a link to access this particular page.
- Preferred language.
- Cookies etc.
The next important topic is Simple Object Access Protocol. This is a communication protocol which allows different programs to interact with each other using hypertext transfer protocol and its extensible markup language also known as XML.
Using HTTP and XML provides the functionality or makes it easier for programs running over different operating systems to easily communicate with each other. It basically specifies how to encode the HTTP header and the XML file so that an application from one system can pass information to another system. It also specifies the response mechanism.
SOAP uses XML and helps a lot by making it easier for applications under different environments to communicate with each other. It is a standard for encoding the messages in XML which invoke the functions in other applications.
It is because SOAP is based on XML that is why it easily enables one system to call a function from other system irrespective of what is the hardware platform, operating system, programming language etc. being used by the two different systems.
For security purposes almost all the applications are behind firewall servers and since SOAP is HTTP-based it does not create any issue in such situations because HTTP is port 80 compliant. HTTP requests are allowed through firewalls and hence using SOAP guarantees smooth communication.
SOAP is language and platform independent and easily passes through proxies and firewalls. It has the ability to use different types of transport protocols be it HTTP or SMTP or any such other protocol.
There are some drawbacks of using SOAP as well, as a few criticize it for being slow because it uses a verbose XML format. Hence it is always recommended to understand the performance limitations before starting to build applications using SOAP. As the request needs to pass through the firewall therefore there could be a communication delay due to firewall taking its time to analyze the HTTP request. There are still lots of firewalls which do not understand the difference between whether HTTP request is coming from a web browser or whether it’s a web service using SOAP.
That being said there are various ways to integrate two applications but SOAP is by far the most used mechanism and is the most easiest to learn. Salesforce also provides programmatic access to your organization however you as a programmer or technical architect need to decide which type of mechanism you should use. You can use Metadata API, BULK API , REST API or SOAP API as per the requirement of the project and feasibility. Metadata API is primarily used to migrate changes from sandbox to production environment. The easiest way of doing so is to use force.com IDE or the migration tool.
Bulk API is also based on REST principles and should be used while dealing with large sets of data. While the REST API provides a strong, easy and simple interface for interacting with Salesforce but it is always recommended to use bulk API in case of large sets of data. Bulk API can be used to perform crud operations asynchronously in other words Salesforce processes these request in batches running in background.
But if you need faster performance or in other words if you are dealing with real-time client applications which need to update few records at the time than always prefer using SOAP API. SOAP API also allows you to maintain passwords, perform searches, and much more. Use SOAP API in any language that supports Web services.
We have got an opportunity to integrate many 3rd party applications using SOAP during our career , one being a very big project involving Integration between SFDC and various SAP modules. If you are curious to learn more about integrating Salesforce using SOAP then join this step-by-step course to master the concepts.
This course takes you from beginner to advanced level and is the most comprehensive course on Salesforce integration available online today.