tags:

views:

1029

answers:

13

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?

Cheers!

+7  A: 

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]

(using [] for the HTML as SO swallows my HTML tags)
then it would be more useful to most clients

David Arno
Have updated my answer to reflect that. Had problems with SO not displaying XML/ HTML tabs :)
David Arno
The correction makes it better (-: Yanking original comment
Murph
+1  A: 

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).

marc
+8  A: 

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.

Mitchel Sellers
It doesn't have to be SOAP - if you're talking about web services (in lowercase) then REST is increasingly common.
John Topley
Very true...let me make a bit of an edit
Mitchel Sellers
+3  A: 

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.

jezell
Sorry Jezelll, had to throw a downvote. This is not what I would consider 'plain english' :( I don't have a problem with the intent of your definition, but using words like 'operation', 'remote server', 'invoked' and 'specification' makes it hard for beginners to understand. See Mitchel Sellers answer as an example of 'plain english'.
David HAust
+1  A: 

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.

Nick
+7  A: 

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!

64BitBob
+5  A: 

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:

  1. You can use a web service to retrieve information about books at Amazon.com
  2. You can use a similar web service to submit an order to Amazon.com
  3. You could CREATE a web service to allow outside applications to find out about product information within your company
  4. you could create a web service to allow outside applications to submit orders to your company.
BradC
+32  A: 

A simple definition: A web service is a function that can be accessed by other programs over the web (Http). To clarify a bit, when you create a website in PHP that outputs HTML its target is the browser and by extension the human being 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.

Vincent Ramdhanie
+1  A: 

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.

Joel Coehoorn
+2  A: 

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.

John Topley
+4  A: 

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.

Christian P.
+1  A: 

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.

RoadWarrior
+1  A: 

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

Archimedes Trajano