Call OSGI restfull service in sling model | Community
Skip to main content
sherybedrock
Level 3
July 27, 2017
Solved

Call OSGI restfull service in sling model

  • July 27, 2017
  • 2 replies
  • 2562 views

Hi all I have created and registred osgi service which returns json string, but I have some problems with calling the service in the sling model. I forgot how is the correct way. Should I use @INJECT Or @OSGIService?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Prince_Shivhare

Agree with Scott, You should use WCMUsePojo while invoking a 3rd party service.

You can find a different examples as well:

Creating an Experience Manager YouTube Component 

Adobe Experience Manager Help | Creating an AEM HTML Template Language Component that displays data from a Restful Web S…

Let us know if you will face any issues.

~ Prince

2 replies

smacdonald2008
Level 10
July 27, 2017

I would look at using WCMUsePojo in this case - then you can call a Restful service from that class and display in the front end of the HTL component - Article and video here:

Scott's Digital Community: Creating an AEM HTML Template Language Component that displays data from a Restful Web Servic…

You do not have to use Sling Model when you want to invoke a 3rd party service from the backend of the HTL component. WCMUsePojo is a better option.

Prince_Shivhare
Community Advisor
Prince_ShivhareCommunity AdvisorAccepted solution
Community Advisor
July 27, 2017

Agree with Scott, You should use WCMUsePojo while invoking a 3rd party service.

You can find a different examples as well:

Creating an Experience Manager YouTube Component 

Adobe Experience Manager Help | Creating an AEM HTML Template Language Component that displays data from a Restful Web S…

Let us know if you will face any issues.

~ Prince