Friday, October 14, 2011

Login in salesforce through .Net Application


1. Download Partner or Enterprice wsdl file from saleforce
 
Setup - > Develope - > API - > Right Click on Generate Partner WSDL ->  Save link As -> Post Fix .wsdl in the file Name

2. Put this wsdl file on a specified location . Lets say I am putting this file in My  D:\ProjectFolder

3. Now Create a window form application.
Click on File - > New -> Project - > Visual C# -> Windows Forms Application
Name of your Project
Location of your application
Now click on OK Button.
4. Go to solution Explorer
Right Click on Project Name -> Click on Add Web Refernce -> If Add web Reference Not Visible then Click On Add Service Reference - > Click On Advance - > Click on Add web Reference -> Put The location where you had your wsdl file.
D:\ProjectFolder is my wsdl location Now include your wsdl file Name
D:\ProjectFolder\FileName.wsdl
Click on Go Button  - > Give the Web Reference Name - > Click On Add Reference Button
Now you have successfully added web service in your .net Application.
5. Now Double Click on Desing Form
6.Now put this code inside the method :
private void method Form_Load(object sender , eventArgs e){

string url = string.Empty;

string SessionId = string.Empty;

  SforceService binding = new SforceService();

LoginResult loginResult = binding.login("username", "passwordWithSecurityToken");

url = loginResult.serverUrl;

SessionId = loginResult.sessionId;


}

Cheers.......................

No comments:

Post a Comment