Exposing AEM Servlet or Service as Rest Service

vikask76191633 20-11-2018

Hi Experts,

I am new to AEM, I am trying to create a wrapper class around an AEM servlets and this wrapper or service, and this will be called by external systems as same as rest service call. This wrapper will call servlet internally.

Data flow:

ExternalSystem >>>> Wrapper class or Service in AEM >> Servlet (which is having business logic), servlet will return json to wrapper or service which will return the response over rest call to external system.

I am aware that that Sling servlets can be exposed as rest call but we dont want to use that as per design.

I am using JAX-RS-Connector for the same but somehow it is not working as expected. I read the same concept at About technologies: Be RESTful on AEM6​ but unsuccessful.

Regards

Vikas

Mark Solution

Are these answers useful?
Help other community members by marking useful answers as accepted.

Accepted Solutions (0)

Answers (4)

Answers (4)

Jörg_Hoh
Employee
20-11-2018

HI Vikas,

I am not familiar with JAX-RS, so what documentation are you using? I am aware of GitHub - wcm-io-caravan/caravan-jaxrs: JAX-RS integration for OSGi-based RESTful micro services.  (and given the latest updates, it looks maintained), but I am not really sure if the JAX-RS style really fits in the fully resourcetype-based approach of Sling.

vikask76191633 20-11-2018

Hi Jörg,

I am adding JAX-RS-connector, Jersery-all, JAX-RS security provider jars via maven dependency in pom. Somehow I am seeing that those dependencies it self are not picked up.

Since servlets are have already written business logics which need to exposed as a service that is why using servlets is the need.

Do you want me to share the code and pom for the same which is I have written ?

Regards,

Vikas

Jörg_Hoh
Employee
20-11-2018

What is your exact problem? What is not working as expected? And why do you want to wrap a servlet? You probably can easily call any OSGI service, it its not necessary to only call servlets.

Jörg