cancel
Showing results for 
Search instead for 
Did you mean: 

Is possible to make a REST Call to webscript from own Java Backed Webscript?

spilby
Confirmed Champ
Confirmed Champ
Hi everybody,

I'm doing a Java Backed Webscript to put in Alfresco and call it via REST. This Webscript must do a set of 3 operations (find a path, create a folder and upload a document).

I read about this and found similar examples to do this operations throw the native Alfresco API, with methods like getFileFolderService, getContentService, etc. of Repository or ServiceRegistry classes. All in Java, without javascript.

But I would rather use REST calls instead of Alfresco API inside my Webscript. I think that if already exists Webscripts to do these operacions, is easier call them than use Alfresco API methods to try to do it. And if the API changes in future versions, the REST calls would remain the same. But I'm new here and I don't know if I'm wrong.

In summary: to do these 3 operacions, one after another, in my backed webscript, what is better and why? Use native API methods or use REST calls to existing webscripts?

And if I try to do the second option, is possible to do this? Using HttpClient class and GetMethod/PostMethod for the REST calls inside my Java Webscript may be the best option for Rest calls?. Or this could give me problems? Because I use a Rest call to my backed webscript that do another rest calls to another webscripts.

Thanks a lot!




1 REPLY 1

romschn
Star Collaborator
Star Collaborator
As you are already writing up a java backed webscript for your functionality, you should use the available APIs for your operation instead of making calls to another webscripts.
However, it is possible to make a webscript call from one webscript to another. You may use RestTemplate, HttpClient to do so.