This is a bare-bones, step-by-step guide for setting up a .NET MVC site to connect to the Salesforce API. Just the facts.
Get the Enterprise WSDL and Security Token
Login to a salesforce.com sandbox to begin. To get to the sandboxes for a live instance of Salesforce, go to the upper right hand and click on your name. Select "Setup" in the menu. Once there you can go to the lower left and click data management, and you will see sandbox listed under there. There is a login button to log in to the sandbox from there.
To generate the WSDL go to Setup => Develop => API => Generate Enterprise WSDL
Click the Generate button and save the resulting file to your computer.
To generate a security token go to Setup => My Personal Information => Reset My Security Token
Click on Reset Security Token to get a security token sent to your email address. You will need that later.
Set up the service reference
Add a service reference in Visual Studio. For the address, enter the path to the WSDL file you downloaded. For the namespace enter SalesforceService, or whatever makes sense for your project.
Binding and endpoint configuration information will be automatically added to your Web.config file.
Add settings in Web.config for the salesforce login. E.g.
<add key="SalesforceUsername" value="[email protected]" />
<add key="SalesforcePassword" value="Qal3jR......" />
The password is a combination of the password used to login to the site and the security token you got earlier.
Use transformations in your Web.Release.config file to set the endpoint and login for the live server.
Working with Salesforce
A small utility file, such as this example, makes working with Salesforce pretty easy.For example, to create a lead:
var sf = new SalesforceUtil();
FirstName = "Joe",
LastName = "Shmoe",
Email = "[email protected]
You may get the following error when your site tries to connect to Salesforce (I did both times I set this up):
Unable to generate a temporary class (result=1).
error CS0030: Cannot convert type 'MySite.SalesforceService.ListViewRecordColumn' to 'MySite.SalesforceService.ListViewRecordColumn'
The fix (which I found here: https://developer.salesforce.com/forums/?id=906F0000000Aj5kIAC) is pretty easy. In the auto-generated Reference.cs file for the service reference, search for this:
and replace it with this:
Posted on February 25, 2016 10:03:40 AM EST by David Hammond
Modern Signal worked with us to understand our needs and figure out what solution would work best for us. Our Lighthouse CMS is perfectly suited to our website goals. When we later needed to modify the CMS, they again took the time to understand exactly what was needed and then built that functionality rather than delivering a cookie cutter solution.
This was by far the smoothest website redevelopment I have ever experienced. Modern Signal was a wonderful company to work with and we greatly value our working relationship.
Modern Signal significantly enhanced our site to be more efficient and user-friendly. They provide excellent customer service with timely and cost-effective solutions.
I love working with Modern Signal! Their CMS is very easy to use and they are incredibly responsive to questions or challenges I bring them.
Modern Signal has been a great partner for us for over the past 10 years. As our business grew and our needs changed, Modern Signal was able to work with us to adjust our website platform in the ever-changing online world. Their service and response level has been second to none, and we've been never been happier with our relationship with them.
Modern Signal understands our business - from future needs to current limitations - so their solutions are always scalable, solid, and service-oriented.
We wouldn’t have gotten where we are today without your support over the years. Modern Signal has always been a great partner to us.
Modern Signal has a professional staff that was very responsive to our needs during all phases - scoping, developing, implementing and maintaining - of our project. We have been pleased with their ability to deliver quality work on time and on budget. If given the opportunity, I would work with them again.
I felt as if my company was their only client. They responded to my needs quickly and efficiently despite short turn around time and intense demands.