Play Games

Search This Blog

Thursday, April 23, 2015

Salesforce Org to Salesforce Org Integration using soap api(Partner wsdl)



Steps:

1) Download the partner wsdl of one org(destination).
setup --> Develop --> api --> Click on Generate Partner WSDL.



Save the file as xml for example partnerwsdl.xml
sample wsdl will be as follows



2)Open another sf org(source).
Goto setup -->develop --> Click on Apex Classes --> click on Generate from WSDl button.


select the downloaded xml file and then click "parse wsdl" button.
It results in generation of four classes.
1)sobjectPartnerSoapSforceCom
2)faultPartnerSoapSforceCom
3)partnerSoapSforceCom
4)AsyncPartnerSoapSforceCom.

3)Now you can interact with partner or destination org as follows.

Open Developer console and place the below code in execute anonymous block.

partnerSoapSforceCom.Soap  s=new partnerSoapSforceCom.Soap ();
String username = 'username';
String password = 'password+securitytoken';

partnerSoapSforceCom.LoginResult lr = s.login(username, password);
s.SessionHeader = new partnerSoapSforceCom.SessionHeader_element();
s.endpoint_x=lr.serverurl;
s.Sessionheader.sessionid = lr.sessionid;
s.getUserInfo();
system.debug('sssssssssssssss'+s.getUserInfo());

Like that you can access different methods from another instance.
Hope it helps you..Enjoy Coding...