Fórum

How to build a servlet for an application hoste in a different server

Gabriel Venegas, modificado 12 Anos atrás.

How to build a servlet for an application hoste in a different server

Junior Member Postagens: 28 Data de Entrada: 10/11/10 Postagens Recentes
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.
thumbnail
Jay Patel, modificado 12 Anos atrás.

RE: How to build a servlet for an application hoste in a different server

Regular Member Postagens: 118 Data de Entrada: 24/02/10 Postagens Recentes
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, modificado 12 Anos atrás.

RE: How to build a servlet for an application hoste in a different server

Junior Member Postagens: 28 Data de Entrada: 10/11/10 Postagens Recentes
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:


HTTP Status 403 - Access denied for 0:0:0:0:0:0:0:1

type Status report

message Access denied for 0:0:0:0:0:0:0:1

description Access to the specified resource (Access denied for 0:0:0:0:0:0:0:1) has been forbidden.
Apache 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.
thumbnail
Mika Koivisto, modificado 12 Anos atrás.

RE: How to build a servlet for an application hoste in a different server

Liferay Legend Postagens: 1519 Data de Entrada: 07/08/06 Postagens Recentes
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:
axis.servlet.hosts.allowed=127.0.0.1,SERVER_IP,0:0:0:0:0:0:0:1
thumbnail
Jay Patel, modificado 12 Anos atrás.

RE: How to build a servlet for an application hoste in a different server

Regular Member Postagens: 118 Data de Entrada: 24/02/10 Postagens Recentes
Thanks Mika for clearing this...

Gabriel, did you try after putting this property?

Regards,
Jay.
Gabriel Venegas, modificado 12 Anos atrás.

RE: How to build a servlet for an application hoste in a different server

Junior Member Postagens: 28 Data de Entrada: 10/11/10 Postagens Recentes
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.
thumbnail
Kamesh Sampath, modificado 12 Anos atrás.

RE: How to build a servlet for an application hoste in a different server

Regular Member Postagens: 158 Data de Entrada: 27/05/10 Postagens Recentes
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, modificado 12 Anos atrás.

RE: How to build a servlet for an application hoste in a different server

Junior Member Postagens: 28 Data de Entrada: 10/11/10 Postagens Recentes
Thanks a lot for the advice Kamesh. Do you know if the versions of these complements are available for liferay 5.2.3?
thumbnail
Jacques Traore, modificado 10 Anos atrás.

RE: How to build a servlet for an application hoste in a different server

Junior Member Postagens: 49 Data de Entrada: 21/01/13 Postagens Recentes
You guys, you saved my life.
Thank you very much