You need to sign in to do that
Don't have an account?

Trouble locating Contact Object Service Reference in .NET
I am able to login to salesforce.com using .NET.
The problem is using any of the standard objects.
I am unable to contruct a Contact or Account object.
I am guessing I need to add the Service Reference?
Not sure how to do that, since I'm still new to .NET
for salesforce.com
Here is my code, sorry code insert does not work!!!:
static void Main(string[] args)
{
string userName = "username";
string password = "password";
string soql = "select LastName,FirstName,TaxID__c from Contact";
SforceService SfdcBinding = null;
LoginResult CurrentLoginResult = null;
SfdcBinding = new SforceService();
try
{
//login
CurrentLoginResult = SfdcBinding.login(userName, password);
//reset the SOAP endpoint.
SfdcBinding.Url = CurrentLoginResult.serverUrl;
//set the session id into the binding
SfdcBinding.SessionHeaderValue = new SessionHeader();
SfdcBinding.SessionHeaderValue.sessionId = CurrentLoginResult.sessionId;
Console.WriteLine("{0}",CurrentLoginResult.sessionId);
QueryResult queryResult = null;
queryResult = SfdcBinding.query(soql);
if (queryResult.size > 0)
{
//put some code in here to handle the records being returned
int i = 0;
Console.WriteLine("Logged in user can see "
+ queryResult.size + " contact records.");
sObject obj = new sObject();
//Lead lead = (Lead)queryResult.records[i];
//string firstName = lead.FirstName;
//string lastName = lead.LastName;
//string businessPhone = lead.Phone;
}
else
{
//put some code in here to handle no records being returned
string message = "No records returned.";
}
Any ideas would be greatly appreciated!
In Salesforce
Select 'Setup' at top of your salesforce home page
Select 'Develop' under App Setup
Select 'API' under Develop
Right click 'Generate Enterprise WSDL' under Enterprise WSDL
Select 'Save Target As'
Save as 'yourFileName.wsdl' as type all files in a location of your choosing
In Visual Studio
Right click your project in the Solution Explorer
Select 'Add Web Reference'
Enter the path and file name of the saved wsdl as the URL in the dialog that opens such as 'c:\myWsdls\foo.wsdl'
Click green arrow
Name the web reference in the right column, I use 'forceWebReference' or something along those lines or leave it defaulted(not recomended).
Click 'Add Reference'
You should now be able to create Contacts etc. using forceWebReference.contact as the type
Keep in mind that contacts are intended to be used as an array of contacts if there will be many
contacts upserted or created etc.
Good Luck
Hope this gets you started.