Retrieve data from database

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Member II

Retrieve data from database

Hello, 

I have a rule that needs to add data coming from an outside RDBMS (MySql) to a document custom model.

Is it possible to call an Http request from javascript within Alfresco?

My call is simply like this "http://<my db server>/Alfresco/XGetDO.php?DO=14569" and it return a json object.

Any help welcomed. Thank you!

Alfresco 5.2

3 Replies
Highlighted
Alfresco Employee

Re: Retrieve data from database

JavaScript Rhino has no support out-of-the-box for httpClients.

There are some exotic alternatives (https://stackoverflow.com/questions/22157910/using-rhino-js-engine-to-make-http-requests) but in this case the recommended alternative is to use a Java Backend service or action.

Software Engineer in Alfresco Search Team.
Highlighted
Member II

Re: Retrieve data from database

Thanks Angel,

I'll give a try even if it is a bit exotic as you say!

Pablo

Highlighted
Senior Member

Re: Retrieve data from database

Our Master Data Alfresco addon for our commercial solution "smart business context services" has such an API but a product may be out of scope? This addon supports read/write access to other enterprise apps and ships with connectors for OpenSource products like MySQL, Postgres or REST-APIs like Redmine, EspoCRM. You could either use the integrated Alfresco Share controls to read/show external data like properties on the fly or you do what ever you whant by accessing the javascript api. In the upcoming version we also support amqp messaging as best practice to trigger modifications from one to many apps, to avoid expensive sync or availability issues.

Pimp Alfresco for Everyday Activities

Please be aware that the solution Angel describes does not cover any error handling. So if you want/need to rely on such a solution you need some java implementation taking care about the protocol stuff and how to handle exceptions.