How to integrate Salesforce with third party ERP, finance systems or any external application.

Step 1: Create an account on Developer Edition of Salesforce.Developer Edition provides access to all of the features available with Enterprise Edition.
Step 2: Regenerate the WSDL file (Generate or Obtain the Web Service WSDL)
To generate the WSDL file for your organization:

1. Log in to your Enterprise, Unlimited, or Developer Edition Salesforce account. You must log in as an administrator or as a user who has the “Modify All Data” permission.
2. Click Setup, and then under App Setup, click Integrate.
3. Click Apex API to display the WSDL download page.
4. Right-click Enterprise WSDL to display your browser’s save options, and save the enterprise WSDL to a local directory.

Step 3: Import it into your environment (Import the WSDL File Into Your Development Platform)

To access an XML Web service from managed code:

1. Add a Web reference to your project for the XML Web service that you want to access. The Web reference creates a proxy class with methods that serve as proxies for each exposed method of the XML Web service.
2. Add the namespace for the Web reference.
3. Create an instance of the proxy class and then access the methods of that class as you would the methods of any other class.

To add a Web reference:

1. On the Project menu, choose Add Web Reference.
2. In the URL box of the Add Web Reference dialog box, type the URL to obtain the service description of the XML Web service you want to access, such as:
3. Click Go to retrieve information about the XML Web service.
4. In the Web reference name box, rename the Web reference to sforce, which is the namespace you will use for this Web reference.
5. Click Add Reference to add a Web reference for the target XML Web service. For more information, see the topic “Adding and Removing Web References” in the Visual Studio documentation.
6. Visual Studio retrieves the service description and generates a proxy class to interface between your application and the XML Web service.

Step 4: When accessing from outside of your company’s trusted networks, you must add a security token to your password to log in to a desktop client, such as Connect for Outlook, Connect Offline, Connect for Office, Connect for Lotus Notes, or the Data Loader.New security tokens are automatically sent to you when your password is changed or when you request to reset your security token.

* login sample
* Prompts for username and password, set class variable binding
* resets the url for the binding and adds the session header to
* the binding class variable

private bool login()
string securitytoken = "5wVvr7MWSwKmWItdcpD4Nl3uY";
string un = "[email protected]";
string pw = "abc123" + securitytoken;

Console.WriteLine("Creating the binding to the web service...");
/* * Create the binding to the sforce servics */

private SforceService binding == new SforceService();
// Time out after a minute
binding.Timeout = 60000;
//Attempt the login giving the user feedback
Console.WriteLine("LOGGING IN NOW....");
loginResult = binding.login(un, pw);
catch (System.Web.Services.Protocols.SoapException e)
// This is likley to be caused by bad username or password
Console.Write(e.Message + ", please try again.\n\nHit return to continue...");
return false;
catch (Exception e)
// This is something else, probably comminication
Console.Write(e.Message + ", please try again.\n\nHit return to continue...");
return false;
Console.WriteLine("\nThe session id is: " + loginResult.sessionId);
Console.WriteLine("\nThe new server url is: " + loginResult.serverUrl);
//Change the binding to the new endpoint
binding.Url = loginResult.serverUrl;
//Create a new session header object and set the session id to that returned by the login
binding.SessionHeaderValue = new apex.SessionHeader();
binding.SessionHeaderValue.sessionId = loginResult.sessionId;
apex.GetUserInfoResult userInfo = loginResult.userInfo;
return true;
This entry was posted in Salesforce and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *