+ Start a Discussion


Hello All,

 I would like to do an hands on with a working solution using SOAP API and REST API.
 Simple practical scenario for SOAP and REST will help with example.
 Could you please provide me with a best source code sample to learn with and explore this integration stuff.

Thanks !!
Amit Chaudhary 8Amit Chaudhary 8

SOAP – Simple Object Access Protocol – is probably the better known of the two models.

SOAP relies heavily on XML, and together with schemas, defines a very strongly typed messaging framework. Every operation the service provides is explicitly defined, along with the XML structure of the request and response for that operation. Each input parameter is similarly defined and bound to a type: for example an integer, a string, or some other complex object. 

All of this is codified in the WSDL – Web Service Description (or Definition, in later versions) Language. The WSDL is often explained as a contract between the provider and the consumer of the service. In programming terms the WSDL can be thought of as a method signature for the web service.


REST – REpresentational State Transfer – is quickly becoming the preferred design model for public APIs. Some interesting statistics regarding the growth of REST in the public sphere are available at, for example, the Programmable Web.

REST is an architectural style, unlike SOAP which is a standardized protocol. REST makes use of existing and widely adopted technologies, specifically HTTP, and does not create any new standards. It can structure data into XML, YAML, or any other machine readable format, but usually JSON – JavaScript Object Notation – is preferred. As can be expected from JavaScript, the objects are not strongly typed. REST follows the object oriented programming paradigm of noun-verb. REST is very data-driven, compared to SOAP, which is strongly function-driven. In the REST paradigm, metadata is structured hierarchically and represented in the URI; this takes the place of the noun. The HTTP standard offers several verbs representing operations or actions you can perform on the data, most commonly: GET, POST, PUT, and DELETE.


Simple Object Access Protocol
It is based on standard XML format
It works with WSDL
Works over with HTTP, HTTPS, SMTP, XMPP

Representational State Transfer
It is based on URI
It works with GET, POST, PUT, DELETE
Works over with HTTP and HTTPS

Please let us know if this will help. Please mark this as solution if this will help you so that if some one has same issue this post can help

Amit Chaudhary
Hi Amit,

 Thanks for your detailed response on SOAP / REST Concepts.
 Could you please share sample code for this, with simple / common use case for both SOAP / REST...
 It will be helpful for hands on...

 Thanks !!
Amit Chaudhary 8Amit Chaudhary 8
Please check below post for REST API

You can create your own Rest API like below code :-
global with sharing class MyRestResource {

    global static void doDelete() {
        RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        String accountId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
        Account account = [SELECT Id FROM Account WHERE Id = :accountId];
        delete account;
    global static Account doGet() {
        RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        String accountId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
        Account result = [SELECT Id, Name, Phone, Website FROM Account WHERE Id = :accountId];
        return result;
    global static String doPost(String name,
        String phone, String website) {
        Account account = new Account();
        account.Name = name;
        account.phone = phone;
        account.website = website;
        insert account;
        return account.Id;

User below request 

{ "attributes" : { "type" : "Account", "url" : "/services/data/v22.0/sobjects/Account/accountId" }, "Id" : "accountId", "Name" : "Acme" }


I hope this will help you
Hi Amit,

 I went through the detailed documention provided. Thank You.
 I understand that, it is quite difficult to do hands on as it requires some built in Applications to Integrate. So, I will try with Salesforce itself.
Suppose, lets take a example of integrating two Salesforce Orgs (Developer Edition - Free) for tesing.
If I create / edit / delete account in one Salesforce Org, it should create / edit / delete its respective accounts in another Salesforce Orgs.
I need to achieve this functionality with both SOAP / REST APIs .
Could you please help me on this ?

Thanks ! 
Amit Chaudhary 8Amit Chaudhary 8
Yes you can do that for same first you need to call SOAP API to get the session of 2nd org then you use above Rest API for DML.

Amit Chaudhary
Ok, Amit.
Do you have any sample code for that ?