简体   繁体   中英

Difference between portlet and a webservice

I am not sure if I am comparing onion with a cabbage. But I am really confused with the portlet and a web service. I know that web service is making your software components in your application as a service to other applications but to me it is similar to a portlet responding to requests. I know that my understanding is making you(Portlet & SAAS developers) really upset. But I need some clarity on this.

Why cannot I use the request-response to portlet work similar to a web service? If yes, what is the benefit I get in using a web service than a portlet? If not, then what are portlets lacking to act as a web service?

I am a newbie in portlet development. Please dont curse me for this question.

Please suggest.

EDIT: Most of the answer say that the portlet is a UI component. My customer has requested me to create a webservice in liferay. So is it to make a portlet as a web service? If yes, can you please provide a pointer or some code snippet?

Addressing your 'edit' specifically with regards to Liferay...

Liferay plugin projects can expose web services without too much work.

The Liferay Service Builder actually has facilities so you can create SOAP web services or JSON web services backed by tables in the Liferay database (and that make queries on existing database tables). In the case of JSON web services, the URL scheme generated is not RESTful (unfortunately), but it is well defined. With a bit of work on your part you can impose Liferay's permission system on web service calls as well.

Here's a reasonable starting point in the Liferay Developer's Guide :

See the links on that page to SOAP and JSON services.

Note that a 'portlet' is only one type of Liferay plugin. The web service facility is part of the service layer - which can be used by many plugin types. So there isn't necessarily a portlet involved in creating a web service in Liferay, you can make a web service that has no visual component associated with it.

Portlets are areas you create to add and display content. Portlets can be added to the left and right of the center body area and can contain myriad content ranging from news, events, calendars, RSS feeds, collections, plain text, and more. Also, you can set properties and policies for showing the portlets.

you want to use portlet when You have content you want to have special focus, like news. You need to specify the configuration data for an item. - ie number of entries to show. You want to give the content editors a choice about when and where to display content. You'd like to show it only to some groups or users.

On the other hand, web services:

  • Enables applications to expose their services “progammatically”, ie the services can be invoked by programs

  • Enables software running on other computers (could be a desktop, mobile phone, PDA, etc.) to invoke operations exposed by Web applications

if you are trying to identify the main difference portal historically, the portlets have three layers architechture (client, middle tier, backend) this cause two weakness:

  1. Different portal groups have no well established way of sharing services
    • Different technologies(Java, Perl, CORBA, EJB) in middle tier.
    • Different protocols(GRAM, IIOP,...)
  2. Consequently, lots of redundancy, reinvention
    • Example: batch script generation

so Web services address the service sharing problem and reduces the redundancy.

source1 source2 source3

Portlets are meant to be a user interface component in a portal solution.

Web Services provide functionality to remotely interact with a system commonly using SOAP, REST, JMS or other related

They provide completely separate functions. The closest you get is the serveResource method in portlets. This functionality is used to serve various types of content from a portlet (such as a PDF document or an AJAX response) without the need to perform a full page request.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM