salesforce integration

Salesforce to Salesforce Integration Using SOAP API

Introduction to SOAP API

  • SOAP API stands for Simple Object Access Protocol API  which supports XML only.
  • It can be used to create, update, delete, retrieve records in any language that supports web services.
  • It is used to maintain passwords, perform searches, retrieve metadata.


  • WSDL stands for Web Service Description Language.
  • SOAP API supports XML only because it uses the WSDL file as a formal Contract between  API and consumer.
  •  It is used to access Salesforce data and business logic handles multiple records in a single invocation.
  • It is XML - the document which is an  XML-document that is used for narrating the functionality offered by a Web Service.

dont miss out iconDon't forget to check out: 6 Ways to Make the Most Out of WordPress Salesforce Integration

SOAP-API also allows you to Salesforce provide two different SOAP API WSDLs (WSDL: Web service description language).

There are two  SOAP API WSDLs:

  1. Enterprise WSDL
  2. Partner WSDL

 Enterprise WSDL(Web service description language)

  • Enterprise WSDL is a strongly typed WSDL for customers 
  • It Changes if modifications are made to an Organization Salesforce Configuration.
  • It is primarily for Customers.

Partner WSDL(Web service description language)

  • Partner WSDL is a loosely typed WSDL for customers 
  • It is used for any Configuration of Salesforce
  • Static and does not change if modification is made to an organization  Salesforce Configuration 
  • It is Primarily for partners

Steps to download the WSDL:

  • Click Setup
  • Type API in Quick find/search
  • Click API and Click Generate Partner  WSDL
  • Download WSDL

Step 1: Expose Webservice as a SOAP API.

global class FetchAccount1
    webservice static Account createAccount(String Name) {
        Account acct = new Account();
        acct.Name = Name;   
        insert acct;

Above code insert account and will return the inserted account.

Considerations for Using the webservice Keyword
  • We can’t use the webservice keyword to define a class or an inner class method, interface, or to define an interface's methods and variables.
  • We can use to define top-level methods and outer class method 

dont miss out iconCheck out another amazing blog by Kirandeep here: What is Wrapper Class in Salesforce - Everything you Need to Know

Step 2: Generate Partner WSDL

Step to generate Partner WSDL

  • Click Setup
  • Type API in Quick find/search
  • Click API and Click Generate Partner WSDL
  • Download WSDL

Step 3: Convert partner WSDL into Apex class

In the source Org Convert  Partner WSDL into Apex Class 


  • Click setup and type apex classes in Quick search/find 
  • Click generate Apex from WSDL and select the saved partner WSDL 

Let us see how to consume webservice through soap API.

string username =' ';  //Target Org username
string password =' ';    //Target Org Password
partnerSoapSforceCom.soap sp = new  partnerSoapSforceCom.soap ();
partnerSoapSforceCom.LoginResult lg = sp.login(username,password);
AccountCreateWIthSoap.AccWebService apexweb = new AccountCreateWIthSoap.AccWebService();
AccountCreateWIthSoap.SessionHeader_element sessionHeader = new AccountCreateWIthSoap.SessionHeader_element();
sessionHeader.sessionId = lg.sessionId;
apexweb.timeout_x =120000;
apexweb.sessionHeader =sessionHeader;
string response = apexweb.createAccount('Anuj');

The above code will create the account in the target Salesforce Org.

Popular Salesforce Blogs