+ Start a Discussion
NileshANileshA 

What is the best way to push Data In and out of Salesforce through Apex?

I need to write an Apex application which pushes data out of salesforce to an external application. The external application processes the records and needs to update them back to salesforce account.
I am using ruby for my external application. Since Ruby does not have great support for SOAP, I have used REST through HTTP Callout to push data out of salesforce. This comes with a limitation, salesforce allows only 10 CallOuts per action. Is there any other way? If not I will get SOAP working for me some how. But following is where I am stuck:

To pass data back to Salesforce, I will have to write global apex class with methods as ‘webService’. But since the WSDL generated is only for authenticated user, how will my external application get the session. Looking at the PHP example at http://blog.jeffdouglas.com/2009/04/05/using-php-to-call-an-apex-web-service/
I find that user name, password are required. But since my application is an apex application and any salesforce user can add and use it, how can I get session for each of the users using the app. I can’t have username, password of each of those.

I am new to Apex and not sure what are the best practices for pushing Data In and out of Salesforce through Apex. Also, not sure if above is actually feasible with Apex in first place.

Afzal MohammadAfzal Mohammad

I would suggest you to use webservice api. You can either go for Enterprise WSDL or Partner WSDL. Use this WSDL and generate a class in your external application. With a little bit of coding, you may easily push/pull data across salesforce and your external application.

 

Hope that helps.

 

Afzal

NileshANileshA

Thanks Afzal.

Partner WSDL could be used but to connect with each of the organizations, I would require the user name passwords of each of them, which I won't have. My Apex application is supposed to be used by multiple organizations. Do you mean I can push back data without having username, passwords. May be my question was not clear enough.

As I googled, I came across this http://boards.developerforce.com/t5/Perl-PHP-Python-Ruby-Development/Connect-login-to-multiple-Customers-organizations-with-single/td-p/154428/highlight/true
Here the moderator has recommended remote access, OAuth 2.0. And that seems to be the only way out for me now.

Thoughts?

Regards,
Nilesh

Afzal MohammadAfzal Mohammad

Yes, OAuth is another option for you.

 

No, without providing authentication details you cannot connect to salesforce. Authentication details can be username/password or session id/server url.

 

However, you may have a third option of using session id and server url to connect to salesforce (meaning no need to provide username and password). You may embed you external application within salesforce UI. You may embed you app using IFRAME or by creating a Custom Web Tab and point it to your app.

 

Hope that helps.

 

Afzal

Manohar SF.ax1874Manohar SF.ax1874

Nilesh, do you remember how you tackle this - "this comes with a limitation, salesforce allows only 10 CallOuts per action. Is there any other way?"

 

thanks

Manohar

DevSFDevSF
Hi @ Afzal.

This is regarding your suggestion to go for Enterprise or Partner WSDL.

So my scenario is....  The external application developer told me that he is going to push the data into salesforce.
As i am new to this integration part.
Can u suggest me how could i get (or) see the data that he has pushed from external website.

Thanks,
Anshul