Foren
How to create REST service in Liferay
Ziaul Chowdhury, geändert vor 13 Jahren.
How to create REST service in Liferay
New Member Beiträge: 5 Beitrittsdatum: 22.03.10 Neueste Beiträge
Hello Guys,
I am a newbie in Liferay.
Requirement:
I'm trying to consume web services of Liferay portal in iPhone by using REST services (XML and JSON).
Questions:
As a newbie, I'm not sure if it is the right way to convert SOAP services to REST service. Please correct me if there is any problem in the procedure which I followed.
Is there any other way to fulfill my requirement?
I'll appreciate any help. Thanks in advance.
Kind regards,
Ziaul
I am a newbie in Liferay.
Requirement:
I'm trying to consume web services of Liferay portal in iPhone by using REST services (XML and JSON).
Questions:
- I have seen in the link that Liferay provides opportunity to access the web services by using JSON. Is it possible to consume web services of Liferay in REST XML format?
- In parallel, I have generated WSDL file of Liferay web services by using Apache Axis 1.4. I want to create Java classes out of the WSDL file in order to make REST services. In order to do so, I have used WSDLToJava command of Axis. It creates Service, ServiceLocator, Stub and some other files. I want to use the procedure explained in the link. In order to do that, I have created a wrapper class which calls the methods from the services and the stubs and it is the @XmlRootElement of Axis. The code looks like the following:
// RootService.java @XmlRootElement public class RootService{ public String getByCity(String city) { String val = null; try{ TestSoapService service = new TestSoapServiceLocator(); TestServiceSoap port = service.getPortlet_Service(); val = port.findByCity(city); } catch(Exception e){ e.printStackTrace(); } return val; }
And the HelloService.java looks like the following:// HelloService.java @Path("/test") public class HelloService { @Path("cityWiseFind") @GET @Produces( { MediaType.TEXT_XML }) public String getByCity() { RootService r1 = new RootService(); String val = r1.getByCity("New York"); return value; } }
When I run this code, tomcat starts properly but I don't get anything in the browser in the REST URL. What could be the reason of that?
As a newbie, I'm not sure if it is the right way to convert SOAP services to REST service. Please correct me if there is any problem in the procedure which I followed.
Is there any other way to fulfill my requirement?
I'll appreciate any help. Thanks in advance.
Kind regards,
Ziaul