Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Gabriel Venegas
How to build a servlet for an application hoste in a different server
August 30, 2011 9:08 AM
Answer

Gabriel Venegas

Rank: Junior Member

Posts: 28

Join Date: November 10, 2010

Recent Posts

Hello all, I hope you can help me.

I need to create a servlet that receive an html request with some post type parameters. Process some information and return an xml file in the response for example, receive a poll id number, do a PollsQuestionLocalServiceUtil.getQuestion(id) for polls portlet and return an xml in the html response with an xml of the information obtained from the service.

Normally I would create a servlet class that extends HttpServlet. Create a service method in it to process the request and write the response, and finally register it in the web.xml file. I don know if this could be achieved in liferay and if it is, Is it possible to still use the services created by the service-builder in the server?

I am using Liferay 5.2.3 and Tomcat 6.0. Is this the correct way to do it? please, if someone knows how to do this or has a tutorial on how to do it, I would really appreciate if you could share this info with me.

Thanks in advance to anyone that might help me.
Jay Patel
RE: How to build a servlet for an application hoste in a different server
August 30, 2011 11:09 PM
Answer

Jay Patel

Rank: Regular Member

Posts: 116

Join Date: February 23, 2010

Recent Posts

Gabriel Venegas:
Hello all, I hope you can help me.

I need to create a servlet that receive an html request with some post type parameters. Process some information and return an xml file in the response for example, receive a poll id number, do a PollsQuestionLocalServiceUtil.getQuestion(id) for polls portlet and return an xml in the html response with an xml of the information obtained from the service.

Normally I would create a servlet class that extends HttpServlet. Create a service method in it to process the request and write the response, and finally register it in the web.xml file. I don know if this could be achieved in liferay and if it is, Is it possible to still use the services created by the service-builder in the server?

I am using Liferay 5.2.3 and Tomcat 6.0. Is this the correct way to do it? please, if someone knows how to do this or has a tutorial on how to do it, I would really appreciate if you could share this info with me.

Thanks in advance to anyone that might help me.


Hi Gabriel,

If I am not wrong then, what you want to achieve is something like..."You want to access data/content of some Liferay entity/DB from such as Polls etc. from some other system"..

If this is what you want to achieve then existing web-services provided by Liferay would be the best fit for you.

Try accessing "http://localhost:8080/tunnel-web/axis"..you will get list of services what Liferay provides...

Best Regards,
Jay.
Gabriel Venegas
RE: How to build a servlet for an application hoste in a different server
August 31, 2011 9:25 AM
Answer

Gabriel Venegas

Rank: Junior Member

Posts: 28

Join Date: November 10, 2010

Recent Posts

Hello Jay, and thanks for your quick response.

You got it right Jay, accessing the polls entities from the liferay database from another application is exactly what I need to do. However, I tried the url you suggested (http://localhost:8080/tunnel-web/axis) to get the list of webservices, instead I got the following error message:

 1
 2HTTP Status 403 - Access denied for 0:0:0:0:0:0:0:1
 3
 4type Status report
 5
 6message Access denied for 0:0:0:0:0:0:0:1
 7
 8description Access to the specified resource (Access denied for 0:0:0:0:0:0:0:1) has been forbidden.
 9Apache Tomcat/6.0.29


Am I missing something? do I need to configue something else?

Please advise

Thanks in advance for any help you might give me.
Mika Koivisto
RE: How to build a servlet for an application hoste in a different server
September 1, 2011 3:55 PM
Answer

Mika Koivisto

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1498

Join Date: August 7, 2006

Recent Posts

Your computer has IPv6 enabled for localhost so you need to add the IPv6 equivalent of 127.0.0.1 to your portal-ext.properties like this:
1axis.servlet.hosts.allowed=127.0.0.1,SERVER_IP,0:0:0:0:0:0:0:1
Jay Patel
RE: How to build a servlet for an application hoste in a different server
September 12, 2011 2:44 AM
Answer

Jay Patel

Rank: Regular Member

Posts: 116

Join Date: February 23, 2010

Recent Posts

Thanks Mika for clearing this...

Gabriel, did you try after putting this property?

Regards,
Jay.
Gabriel Venegas
RE: How to build a servlet for an application hoste in a different server
September 12, 2011 3:29 PM
Answer

Gabriel Venegas

Rank: Junior Member

Posts: 28

Join Date: November 10, 2010

Recent Posts

Helo Patel, after I modified the property I was able to get the list of services. However I didn knew how to use those, so I created the servlet manually and added the servlet mapping in web.xml manually. I imported the local services in the class and it worked perfectly.

Thanks everyone for their help.
Kamesh Sampath
RE: How to build a servlet for an application hoste in a different server
September 12, 2011 8:29 PM
Answer

Kamesh Sampath

Rank: Regular Member

Posts: 159

Join Date: May 26, 2010

Recent Posts

please check with the client files that are available as part of additional files download in the Liferay Distribution Download. You need to create the Web Services client ofr consuming these services, for testing purposes you can use SOAP UI, if you want to consume them from your Portlets please develop a client


Hope this is the information you are looking for.

~Kamesh
Gabriel Venegas
RE: How to build a servlet for an application hoste in a different server
September 13, 2011 3:32 PM
Answer

Gabriel Venegas

Rank: Junior Member

Posts: 28

Join Date: November 10, 2010

Recent Posts

Thanks a lot for the advice Kamesh. Do you know if the versions of these complements are available for liferay 5.2.3?
Jacques Traore
RE: How to build a servlet for an application hoste in a different server
October 3, 2013 8:16 AM
Answer

Jacques Traore

Rank: Junior Member

Posts: 46

Join Date: January 21, 2013

Recent Posts

You guys, you saved my life.
Thank you very much