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
Vimal BhavsarVimal Bhavsar 

How to fetch External Database Value by web service in Salesforce.

Hi Team,

Please tell me how can i fetch the value of any external databse to salesforce. can it'll be done with the help of webservice or is there any otherway to do this?

srlawr uksrlawr uk
As far as I am aware, you can't directly access many major database technologies directly from salesforce (ie. send a query string to mySQL), but what you can do is make web service callouts to a service that exposes your database information? Without any details on your database/technology setup, I can't advise any further on that, but if you can/have exposed your external database via a web service, I'd recommend using RESTful call outs to access it from Salesforce.

Basically you will want to create a new Apex class representing your call out functionality, and use the built in Apex from WSDL request library to construct a webservice call out (much like the one for the Amazon example) or you can roll your own.

I prefer to write my own, and here is some starting infomation on this process..
https://developer.salesforce.com/page/Apex_Web_Services_and_Callouts#HTTP_.28RESTful.29_Services

You can set all your header and authenticaltion informaiton using the built in HttpRequest library (http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_restful_http_httprequest.htm#apex_classes_restful_http_httprequest), and then make your call out with http.send(req);

Which returns your HTTPResponse object, that you can then parse. Read
https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_restful_http_httpresponse.htm
for more information on that.

If you don't yet have a webservice exposing your external database, you have tonnes of options in the computer science arena(!!) you could use a simple PHP script on a web server, or a complex Java application. You can also use loads of integration tools to expose your database information to salesforce, including free ones (like Talend) and paid ones (like Jitterbit).