Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Exposing AEM Servlet or Service as Rest Service

Avatar

Level 1

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

4 Replies

Avatar

Employee Advisor

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

Avatar

Level 1

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

Avatar

Employee Advisor

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.

Avatar

Level 10

We did an old article that shows how to invoke a Servlet from AEM service - Adobe Experience Manager Help | Invoking Adobe Experience Manager Sling Servlets using Apache HTTP A...

It was written for AEM 5.x - but will give you an idea.