Difference between portlet and a webservice - web-services

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. - i.e. 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”, i.e. 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:
Different portal groups have no well established way of sharing services
Different technologies(Java, Perl, CORBA, EJB) in middle tier.
Different protocols(GRAM, IIOP,...)
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.

Related

Consume Web Service in Drupal?

Trying to understand which of the better modules to use for my page's specific need. Services module is popular, but that seems more for providing service, where the Web Service Client is good for consuming a web service.
Here's the requirement:
On the web page, I've got a form whose fields (location, service areas, region, indicators, etc) are to be built dynamically and some are selectable based on other selections. (So choosing worldwide would make Hubzone 8A not appear.)
Another team built the SOAP web service, it sits on another server outside the web server. What they delivered to me is a URL to invoke, basically an XML file:
http://webserviceurl.com:52901/navigator/NavigatorServices?wsdl
(Obviously, I just can't use the Feeds module to import the XML manually, right? The whole point of the web service approach is that as the data in the web service is updated, the Process form will by dynamic.)
So I'm really at the beginning of this. Need some guidance.
Web Service Client and SOAP Client are the ones that should do the work for you.
If you find it difficult to understand how to use them, you can simply use nuSOAP library + some PHP code inside a module. This article provides a good tutorial about providing and consuming Web Services using nuSOAP.
PHP provides a SOAP API. So you can simply create a module using this API (and Drupal Form API).

where to use web services

I am discovering webservices to impliment in my asp.net website. I visited many sites about Why use webservices and read many articles and found out that web services are good when you have something that is used frequently without loading your page.
I want to know some other example scenarios where web services are used.
Whether i can use web services in sending an order form to database or it is just for textbox box auto completion like google and etc.
Note: I know web services can be used from mobile, web or desktop applications.
But My question is When do i use web service in ASP.Net Application?
Some articles read so far
Codeplex
How to create a Web service using Visual Studio.net
w3school
On a Large Scale, Webservices are basically written, when you want to expose your database, your code, to some other user.
By exposing database, means, suppose, you have a large collection of all the pharmaceutical companies in a given region, storing details in db like, medicines they produce, their policies etc etc. And now, you want people to use it(possibly your paid Client, or simply free access to anyone). So what you going to do? Obviously broadcasting working connectionString to your database will be a disastrous move.
So what you do is to make few methods on top of your db i.e. CRUDE operations and expose these methods in your WebService i.e. someone can interact with these methods through a URL and fetch data or send data or both.
Most general use of WebServices is when you want your specific language built( say ASP.NET) logic and data to be accessible to people on different platforms.
Like mobile devices. Their frontEnd is built in fancy framework say like Titanium, but they fetch their data through a Sql Server using WebService built with Microsoft's WCF-Rest approach. They store their data, Synch their data through a WebService.
In a typical example, We had a very large shopping Website, and it was standalone i.e. we were the only users of its database, its data, its users. But then a requirement came, that certain Client wants to model it and make use of its existing data and logic, but they have got JAVA platform. Our entire system was built on ASP.NET 3.5. What to do then. We simply exposed our BAL through a ServiceLayer and gave it a fancy name ServiceBAL and lived (and earned) happily ever after.
These are some business oriented usage of Web Services.
Other simple, mere usage of webService like textBox auto completion, existing user check and so many, am sure, you must have found out during your scout.
Web services are reusable components you can use anywhere. for example suppose you are building order processing system where order can be place by mobile,web etc. So instead of creating a different function for different application or different platform it's better to create a web service of order processing system such as placeOrder or takeOrder web service and consume them on different applications.
Web Services are the means by which devices communicate over the World Wide Web.
Whether you use a mobile application, search engine or an enterprise system, the user piece of the application (the interface) resides on your device.
The data, and potentially the business rules, live on some other server on the network. How your interface communicates with the server piece is the role of Web Services.

Difference between web services and web application

Lets have an example scenario:
Client opens a web site and finds the sum of two numbers which he enters from the textboxes.Then clicks on the ADD button.Two parameters are HTTP GET'ed to server where PHP code is written to add the numbers and result is echo'ed.
Based on this scenario could anybody explain the difference between Web services and application?
In your case if you have User Interface for providing two numbers and then getting the result, it should be called a web application. But if you have an API exposed to receive two numbers and return result over http , then it should be called a web service.
At low level, both Web application and web service are kind of same thing. But the main point is that web services are for machine/program to machine/program communication whereas Web application is for Users.
I'd say that web applications are intended for users and web services are intended for other applications. That's the most important difference. Web applications usually present data in HTML which looks nice to the user and web services usually present data in XML which easy to parse by other applications.
A person drives a car. That car could be powered by an internal combustion engine, electric motor, or nuclear reactor. The power source doesn't matter to the driver though, as all they need to see are the controls and the road ahead.
The application is the car. Web services are the nuclear reactor.
To add 2 no.s we write a web service, to subtract we write a diffrent web service, however calculator is an web application that uses add,subtract and many other webservices in combine.
Lets take an example of Google search.
We can use Google search in two ways. First, we can visit http://www.google.com and put out query for search. Google the returns the result. Second, we can integrate Google Search in our websites with custom search API.
In first case Google Search is acting as web application while in second example it is acting as web service.
Here we can point out few differences,
User interacts with web application while machine interacts with web service.
To access web application, one must visit application. While web service can be access from anywhere (from any application which integrated it). We don't need to visit the service explicitly.
A webservice is equivalent to a method in java that has a web wrapper around it. It lives on the server and it can be sent data / queried etc. and may or may not return a result. It does not have any front end it can only be accessed via http get, put, delete etc.
A web Application is a fully functional piece of software that lives on a sever that is designed to help people achieve a task. This would have a front end that would allow users to interact with it / enter data etc.
A web application could use multiple webservices to achieve its goal / end result
There is little difference between web application and web services.
Web Application: In web application when user request any data then the server embeds the response into some HTML and forward it to the user and on browser the HTML is rendered.
While in web services it's done differently that when some user requests for some data then the server returns it a json or XML array of objects and the data can be displayed by anyway the web designers wants.
Thanks Hope it resolves the matter.
Web service is for application consumption , invoked through web application
To communicate with webservice data should be sent as SOAP message or as REST i.e XML over HTTP
Most of the times web service is not part of application because to facilitate the use by other web applications and it is not for direct consumption to end users
Web application is for human consumption invoked directly by GUI which may or may not use web service for giving response

What is web-service and how to develop it

I am looking for some good starting point for developing web-service.
I have one application which has C++ library support using which I can get all the details of the product.
I am supposed to write web service SDK for the same.
Any help.
Web services generally refer to a technique that allows code to be called via HTTP requests and responses. This is similar to a web page, except that what is returned from a web service is usually not HTML intended to be displayed in a browser - it is usually data of some kind.
"Web Service" is one of those terms that means whatever the person saying it means. Basically, its just a way to access data or functionality via http. There's a few standardized methods - REST, SOAP for web services, or you can just serve up XML, JSON, or other data from a plain old server side web app.
What you'd want to do is investigate what form this Web Server you are supposed to write needs to be in (SOAP, REST, something else), and then go from there.

What is a "web service" in plain English?

I've been reading about "web services" here on SO, on Wikipedia, Google, etc., and I don't quite understand what they are. What is the plain English definition/description?
If I make a simple website using PHP that just, say, prints a random integer to the page... is this a "web service"? If not, why not?
A simple definition: A web service is a function that can be accessed by other programs over the web (HTTP).
For example, when you create a website in PHP that outputs HTML, its target is the browser and by extension the human reading the page in the browser. A web service is not targeted at humans but rather at other programs.
So your PHP site that generates a random integer could be a web service if it outputs the integer in a format that may be consumed by another program. It might be in an XML format or another format, as long as other programs can understand the output.
The full definition is obviously more complex but you asked for plain English.
Simplified, non-technical explanation:
A web serivce allows a PROGRAM to talk to a web page, instead of using your browser to open a web page.
Example:
I can go to maps.google.com, and type in my home address, and see a map of where I live in my browser.
But what if you were writing a computer program where you wanted to take an address and show a pretty map, just like Google maps?
Well, you could write a whole new mapping program from scratch, OR you could call a web service that Google maps provides, send it the address, and it will return a graphical map of the location, which you can display in your program.
There is a lot more to it, as some of the other posts go into, but the upshot is that it allows your application to either retrieve information FROM, or submit information TO some resource. Some other examples:
You can use a web service to retrieve information about books at Amazon.com
You can use a similar web service to submit an order to Amazon.com
You could CREATE a web service to allow outside applications to find out about product information within your company
you could create a web service to allow outside applications to submit orders to your company.
Yes that is a simple web service.
Web services are really nothing more than a request/ response mechanism that allows a client to remotely access/ modify data. There are formal standards for web services (SOAP, SOA etc), but your simple page is a service too.
The main downside to printing it to a page is that your service would return HTML. Preferable data formats are JSON and XML, because most client frameworks (and server frameworks) are designed around using JSON and XML.
So if you modified your service to return:
<RANDOM>some random number</RANDOM>
rather than:
<HEAD>...</HEAD>
<BODY>some random number</BODY>
then it would be more useful to most clients
In over simplified terms a web service is something that provides data as a service over the http protocol. Granted that isn't alway the case....but it is close.
Standard Web Services use The SOAP protocol which defines the communication and structure of messages, and XML is the data format.
Web services are designed to allow applications built using different technologies to communicate with each other without issues.
Examples of web services are things like Weather.com providing weather information for that you can use on your site, or UPS providing a method to request shipping quotes or tracking of packages.
Edit
Changed wording in reference to SOAP, as it is not always SOAP as I mentioned, but wanted to make it more clear. The key is providing data as a service, not a UI element.
A web service differs from a web site in that a web service provides information consumable by software rather than humans. As a result, we are usually talking about exposed JSON, XML, or SOAP services.
Web services are a key component in "mashups". Mashups are when information from many websites is automatically aggregated into a new and useful service. For example, there are sites that aggregate Google Maps with information about police reports to give you a graphical representation of crime in your area. Another type of mashup would be to take real stock data provided by another site and combine it with a fake trading application to create a stock-market "game".
Web services are also used to provide news (see RSS), latest items added to a site, information on new products, podcasts, and other great features that make the modern web turn.
Hope this helps!
The best plain English explanation comes from using an analogy:
Web pages allow people to communicate and collaborate with each other.
Web services allow programs to communicate and collaborate with each other.
Your PHP example is a web service by that definition, because the output could be consumed by another program. But in reality, HTML screen-scraping is not a reliable or maintainable way of producing web services.
For most sites you have HTML pages that you visit when you use your browser. These are human-readable pages (once rendered in your browser) where a lot of data might be crammed together, because it makes sense for humans.
Now imagine that someone else want to use some of that data. They could download your page and start filtering out all the "noise" to get the data they wanted, but most websites are not built in a way where data is 100% certain to be placed in the same spot for all elements, so in addition to being cumbersome it also becomes unreliable.
Enter web services.
A web service is something that a website chooses to offer to those who wish to read, update and/or delete data from your website. You might call it a "backdoor" to your data. Instead of presenting the data as part of a webpage it is provided in a pre-determined way where some of the more popular are XML and JSON. There are several ways to communicate with a webservice, some use SOAP, others have REST'ful web services, etc.
What is common for all web services is that they are the machine-readable equivelant to the webpages the site otherwise offers. This means that others who wish to use the data can send a request to get certain data back that is easy to parse and use. Some sites may require you to provide a username/password in the request, for sensitive data, while other sites allow anyone to extract whatever data they might need.
A web service is a collection of open protocols and standards used for exchanging data between applications or systems. Software applications written in various programming languages and running on various platforms can use web services to exchange data over computer networks like the Internet in a manner similar to inter-process communication on a single computer. This interoperability (e.g., between Java and Python, or Windows and Linux applications) is due to the use of open standards (XML, SOAP, HTTP).
All the standard Web Services works using following components:
SOAP (Simple Object Access Protocol)
UDDI (Universal Description, Discovery and Integration)
WSDL (Web Services Description Language)
It works somewhat like this:
The client program bundles the account registration information into a SOAP message.
This SOAP message is sent to the Web Service as the body of an HTTP POST request.
The Web Service unpacks the SOAP request and converts it into a command that the application can understand.
The application processes the information as required and responds with a new unique account number for that customer.
Next, the Web Service packages up the response into another SOAP message, which it sends back to the client program in response to its HTTP request.
The client program unpacks the SOAP message to obtain the results of the account registration process.
Simple way to explain web service is ::
A web service is a method of communication between two electronic devices over the World Wide Web.
It can be called a process that a programmer uses to communicate with the server
To invoke this process programmer can use SOAP etc
Web services are built on top of open standards such as TCP/IP, HTTP
The advantage of a webservice is, say you develop one piece of code in .net and you wish to use JAVA to consume this code. You can
interact directly with the abstracted layer and are unaware of what
technology was used to develop the code.
Webservice is a technology by which two or more remote web applications interact with each other over network/internet. It can be implemented using Java, .net, PHP etc.
Features of Web service:-
Using web services two or more systems exchange data over network. Data are exchanged either using XML or JSON.
Any web service has two parts Server end where the service is deployed and the client part where the service is accessed by its clients. Any web service can have multiple clients. When a travel portal is selling tickets of an airliner. Portal is client and the Airline is the server as it is selling its service.
Web services can be synchronous or it can be asynchronous also.A web application can interact with many web services but these web services are loosely coupled with their client web applications. That means any change in the parent application has little or no effect on the web services or vice versa.
Web services can carry attachment document also like PDF, Word etc. with its XML payload. Java provides separate API for this type of web services.
A web service always hides the internal complexity of the service to its clients. For an example, an airliner which is selling tickets via a third party portal is only gathering end user info via a web service and in return it is providing ticket. The portal which is selling ticket doesn't have to bother about the internal complexity of the airlines ticket reservation systems.
A web service can be of fire and forget type or it can return something. Suppose, a web application just want to send some info to a third party application. The sender doesn't need any acknowledgement from the receiver. In this type of scenario we need a fire and forget type of web service.
A web service, as used by software developers, generally refers to an operation that is performed on a remote server and invoked using the XML/SOAP specification. As with all definitions, there are nuances to it, but that's the most common use of the term.
An operating system provides a GUI (and CLI) that you can interact with. It also provides an API that you can interact with programmatically.
Similarly, a website provides HTML pages that you can interact with and may also provide an API that offers the same information and operations programmatically. Or those services may only be available via an API with no associated user interface.
Well,
As #Vincent Ramdhanie has said that a web service is not meant to be seen / consumed by end user but another program. So technically logic in your program will be:
In case of acting as a normal program
user on website -> HTML/JS/JQuery etc -> give me a random number ->ur program
Now
ur program -> generate random number -> generate HTML and encapsulate o/p -> go back to user
but in case of web service the flow changes a little:
user -> my application -> XML/JSON/some other format -> give me a random number ->ur program
Now
ur program -> generate random number -> generate XML/JSON/some other format -> my application -> generate HTML and encapsulate o/p -> go back to user
Hope this helps :)
A simple definition would be an HTTP request that acts like a normal method call; i.e., it accepts parameters and returns a structured result, usually XML, that can be deserialized into an object(s).
Web services are almost like normal a web page. The difference is that they are formatted to make it very easy for a program to pull data from the page, to the point of probably not using any HTML. They generally also are more reliable as to the consistency of the format, may use a different formal process to define the content such soap or raw xml, and there is often also a descriptor document that formally defines the structure for the data.
A way of sending a message to invoke an operation on another computer. The difference between web services and previous methods is what gets sent over the wire is standardized at a higher level.
Old way: describe endians, encoding, port numbers, etc.
Web Service: URL, XML
Web Service is like a medium of commuication between two unrelated programs. The programs use a specified protocol(Usually Simple Object Access Protocol (SOAP)) as medium to understand what REQUEST/RESPONCE they are to process/execute on there respective end.
A web service defines a contract of actions that a server will perform for you. The format and protocol doesn't really matter, but you should have some set definition of how the communication happens.
In your example, it depends, if that is being used in another application that reads that number, yes it is service, otherwise, it's just a webpage with a number.
In simple words Web service could be any simple program ex: add two numbers which should be published over the UDDI and can be consumed by another program.WSDL will have the endpoint to locate the webservice and also the binding and port details.
'Web Service' is composed of two words,'Web' and 'Service'.
What is 'Web'? 'Web' means 'World Wide Web'.
'Service' for what? Not for Human,if so,it's 'Web Page',such as text,images,video etc.
It's for Programs to communicate through the Internet using the same technology the 'Web' used,such as TCP,HTTP etc.
'Service' also means it provides some functions,like the 'Service Layer' in CRUD.
There are mainly two types:
1. SOAP(Simple Object Access Protocol)
2. RESTful(Representational state transfer)
Without prejudice to other definitions I would say that a web service is software system that allows for inter-operable machine-to-machine / application-to-application interaction over a network. This generic definitions would also help consider REST architectures to be a web service as they provide similar functionality albeit being an architectural style unlike the SOAP which is a fully defined protocol.