Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Call OSGI restfull service in sling model

Avatar

Level 3

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?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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 ...

Let us know if you will face any issues.

~ Prince

View solution in original post

2 Replies

Avatar

Level 10

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 ...

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.

Avatar

Correct answer by
Community Advisor

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 ...

Let us know if you will face any issues.

~ Prince