RE: WEB Services JAX-RS

Juraj Károly, modified 6 Years ago. New Member Posts: 11 Join Date: 3/25/18 Recent Posts
I have folleowed the instructions for deploying a simple web service to Liferay portal:


https://dev.liferay.com/de/develop/tutorials/-/knowledge_base/7-1/jax-rs

As written there, I have created an OSGi Module using an Maven REST Archetype.

I have depooyed it to Liferay Community Edition Portal 7.1.2 CE GA3.


I am ablo to obtain the access_token from Liefray, but when I want to call the service with curl (on a localhost - exactly like in the tutorial), than there is no response (see attacheed iamge).

Attachments:

Tech Savvy, modified 6 Years ago. New Member Posts: 3 Join Date: 1/11/18 Recent Posts
Follow this link which shows step by step implementation of JAX-RS
https://www.youtube.com/watch?v=0F2onRk4WYA
thumbnail
Eric COQUELIN, modified 6 Years ago. Expert Posts: 254 Join Date: 11/3/13 Recent Posts
When starting on something new, you should start with the easiest scenario and then move to more complex thing.

I would first test your service after disabling authentication.

This can be acheived with following code as the header of your main REST application

@Component(
    property = {
        JaxrsWhiteboardConstants.JAX_RS_APPLICATION_BASE + "=/yourpath",
        JaxrsWhiteboardConstants.JAX_RS_NAME + "=Your.Application.NAME",
        "liferay.auth.verifier=[b]false[/b]",
        "liferay.oauth2=[b]false[/b]",
    },
    service = Application.class
)
public class YourRestApplication extends Application {
...
}
Then try again your curl command.
Juraj Károly, modified 6 Years ago. New Member Posts: 11 Join Date: 3/25/18 Recent Posts
Helllo, thanks for your support.

I have finally got the example from Liferay Site to work. I have had to add following line to the JAX-RSn Application Class:

"oauth2.scopechecker.type=none"


@Component(
     property = { 
          JaxrsWhiteboardConstants.JAX_RS_APPLICATION_BASE + "=/greetings",
          JaxrsWhiteboardConstants.JAX_RS_NAME + "=Greetings.Rest",
          "oauth2.scopechecker.type=none"
     }, 
     service = Application.class
)
public class MyRestApplication extends Application {
...
}