function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
mc1392mc1392 

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!

SuperfellSuperfell
Have you walked through the quick start in the API docs ?
LBJLBJ

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.