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
Pablo RoldanPablo Roldan 

call apex method through API

Hi All,

I know that it's possible to call apex methods through the API or maybe something like that with executeAnonymous().
However, I am not really sure about that, so my question is if it's possible to call apex methods and get the result through the API or another way out salesforce?
If it's possible could you tell me how?

Thanks in advance.
Best Answer chosen by Pablo Roldan
Satish_SFDCSatish_SFDC
Ok got it now.
So you would like to create your own application (in C#) which connects to the salesforce and gets or updates data.

Alright:
There are two ways for this.
One through the SOAP API and the other through the REST API.

In case of SOAP API, you will have to download the WSDL File. There are two WSDL's - Partner and Enterprise WSDL. Partner WSDL is kind of loose binding to the salesforce, so you can use the same app for multiple orgs. Enterprise WSDL is the opposite. 

Once the WSDL is downloaded, you will add the wsdl as a reference in your .NET app.

Thats it. You now have access to the methods in apex.

More instructions here.
http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_quickstart_steps.htm

Hope this helps.

Regards,
Satish Kumar

All Answers

Satish_SFDCSatish_SFDC
Are you trying to get some data out of salesforce.
You probably have to use an SOQL query.
Open  your developer console and just type in your SOQL query in the query editor at the bottom.

A sample SOQL query would be like
Select ID, Name From Account LIMIT 10

Hope this helps.

Regards,
Satish Kumar
Pablo RoldanPablo Roldan
Hi Satish_SFDC,

Thanks for replying, although that is not the response which I was looking for.
I trying to execute Apex Methods in my project in C# and get the info into this. I don't try to make a SOQL through the API or in or out salesforce.

Thanks in advance
Satish_SFDCSatish_SFDC
Ok got it now.
So you would like to create your own application (in C#) which connects to the salesforce and gets or updates data.

Alright:
There are two ways for this.
One through the SOAP API and the other through the REST API.

In case of SOAP API, you will have to download the WSDL File. There are two WSDL's - Partner and Enterprise WSDL. Partner WSDL is kind of loose binding to the salesforce, so you can use the same app for multiple orgs. Enterprise WSDL is the opposite. 

Once the WSDL is downloaded, you will add the wsdl as a reference in your .NET app.

Thats it. You now have access to the methods in apex.

More instructions here.
http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_quickstart_steps.htm

Hope this helps.

Regards,
Satish Kumar

This was selected as the best answer
Pablo RoldanPablo Roldan
Hi Satish_SFDC,

So close, although it's not exactly the thing that I wanted.
The only thing that I needed to know, after your response, was how I can execute an apex method from my .Net app. And I have found this website: http://whiterabbitservices.com/2011/04/01/calling-a-custom-salesforce-apex-web-service-from-c/
 
So, I have deduced that I need two WSDL, one it's the enterprise WSDL and the other is the Apex WSDL.
Now I'm going to try to create an app to see if that works. I will tell you.

If you see anything that it's wrong, please tell me.

Thanks in advance.
Pablo RoldanPablo Roldan
Hi Satish,

I have fixed it. I have used the wsdl from the apex class, and then import it to the project.
Finally, I have called the method which it's a webservice, and this give me the return of this method.

So, thank you so much for your help :)
Mohit Gupta 125Mohit Gupta 125
Pablo, Can you please share the piece of code that you use to execute Apex in .Net