留言板

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

Gabriel Venegas,修改在12 年前。

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

Junior Member 帖子: 28 加入日期: 10-11-10 最近的帖子
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,修改在12 年前。

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

Regular Member 帖子: 118 加入日期: 10-2-24 最近的帖子
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,修改在12 年前。

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

Junior Member 帖子: 28 加入日期: 10-11-10 最近的帖子
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,修改在12 年前。

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

Liferay Legend 帖子: 1519 加入日期: 06-8-7 最近的帖子
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,修改在12 年前。

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

Regular Member 帖子: 118 加入日期: 10-2-24 最近的帖子
Thanks Mika for clearing this...

Gabriel, did you try after putting this property?

Regards,
Jay.
Gabriel Venegas,修改在12 年前。

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

Junior Member 帖子: 28 加入日期: 10-11-10 最近的帖子
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,修改在12 年前。

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

Regular Member 帖子: 158 加入日期: 10-5-27 最近的帖子
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,修改在12 年前。

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

Junior Member 帖子: 28 加入日期: 10-11-10 最近的帖子
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,修改在10 年前。

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

Junior Member 帖子: 49 加入日期: 13-1-21 最近的帖子
You guys, you saved my life.
Thank you very much