Reputation: 899
I'm trying to implement REST service in a liferay portlet. Found no way other than using JSON web services in liferay. I don't need to implement web services to interact with the database directly, meaning I dont want to build services to use Json web service. Is there anyway to implement REST web services in a liferay portlet without involving service building, more like a custom web service? Also provide any examples available if possible.
Thanks in advance.
Upvotes: 1
Views: 5238
Reputation: 1060
Since Liferay version 7.0 there is support in Liferay for deploying JAX-RS endpoints as OSGi services.
In Liferay 7.0 you need to use what is called RestExtender (https://dev.liferay.com/es/develop/tutorials/-/knowledge_base/7-0/jax-ws-and-jax-rs)
From Liferay 7.1 version there is also support for JAX-RS OSGi Whiteboard, which also allows to deploy JAX-RS applications as services and adds a lot more flexibility (https://osgi.org/specification/osgi.cmpn/7.0.0/service.jaxrs.html) (https://dev.liferay.com/es/develop/tutorials/-/knowledge_base/7-1/jax-rs)
Upvotes: 1
Reputation: 2862
For Spring based portlets, there's an excellent and still valid blog Using RESTFul services with Liferay that describes implementing REST services with Spring MVC controllers and Liferay PortalDelegateServlet
.
Another option might be to handle the REST calls as resource requests (it. to implement a controller with resource mappings - @ResourceMapping
).
Upvotes: 2