Foros de discusión

JSON Web Service get user info

steve marion, modificado hace 9 años.

JSON Web Service get user info

New Member Mensajes: 4 Fecha de incorporación: 19/09/14 Mensajes recientes
Hello,

I'm setting up a JSON web service using liferay remote service with service builder.
I've successfully opened a web service that I can call remotely with basic authentication.
How can I get the user info from inside the web service ?

@JSONWebService(value = "ping", method = "GET")
	public String getPing() {
		//user.getName() ?
}


It is said in the documentation :

some parameters are made available to the web services by default. [...]
Here are the default parameters:

userId: The id of authenticated user
user: The full User object
companyId: The users company
serviceContext: The empty service context object


How can I read these param from my web service method ?

Thank you.
Ranjit Reval, modificado hace 9 años.

RE: JSON Web Service get user info

New Member Mensajes: 13 Fecha de incorporación: 25/06/14 Mensajes recientes
Please check following link it may be helpful to you.

http://www.liferaysavvy.com/2014/05/consuming-liferay-json-web-services.html
steve marion, modificado hace 9 años.

RE: JSON Web Service get user info

New Member Mensajes: 4 Fecha de incorporación: 19/09/14 Mensajes recientes
Thank you for your response,

Unfortunately, this page and linked pages on the same website do not show how to retrieve context information like user from the web service method.
steve marion, modificado hace 9 años.

RE: JSON Web Service get user info

New Member Mensajes: 4 Fecha de incorporación: 19/09/14 Mensajes recientes
Ok, I found the solution :
you can access these object using super class method like "getGuestOrUser()"
Brahma Teja Ponnuru, modificado hace 8 años.

RE: JSON Web Service get user info

New Member Mensajes: 12 Fecha de incorporación: 9/09/15 Mensajes recientes
Hi Steve,

Thanks, the method is getGuestOrUser() is not available in the <entity>LocalServiceImpl. But it is available in <entity>ServiceImpl