29

Just started with web-services so pardon me if my question sounds stupid.

Why do we need web-services? How are they different from normal web applications?

Two uses have been mentioned in many of the tutorials. One is the communication between different machines/applications, which sounds fine. But the next one is to develop reusable application components. My question is, do we need web services for that purpose?

For Eg: A Currency converter can be implemented as a web service and it can be published on a url. But then, the same can be created as a web-application. Where is the actual advantage of using web-services?

Also as per some posts in SO, webservices should be used if no UI is involved and web-applications if a gui is required. Is the choice all that simple?

Note: Here I'm referring to SOAP based web-service. RESTful ones might be different.

Chillax
  • 4,418
  • 21
  • 56
  • 91

4 Answers4

9

Web services (esp SOAP) are designed to be consumed / read / used by other programs. If you've ever had to write a "screen scrape" program (i.e., operate a web application and pick out the data you need from all the goo that makes the page pretty and friendly for the user) you'll appreciate the structure.

Also as per some posts in SO, webservices should be used if no UI is involved and web-applications if a gui is required. Is the choice all that simpe?

In a nutshell, "yes".

Dan Pichelman
  • 2,312
  • 2
  • 31
  • 42
  • So providing a service like currency converter, stock quotes etc on a webpage as a web-service is not advantageous? We should be using them only when they are being used by other programs? – Chillax Sep 04 '12 at 21:06
  • 4
    Try going to the FedEx web site and get the tracking details for a package. Do a 'view source' on every page that comes back. Imagine writing code for that, and to be durable to handle changes when FedEx changes their web page. Then imagine having a "function call" that you can make where you just enter a tracking number and get back the data you need without having to parse all the extra goo. Soap header bytes are usually stripped out by your interface; you rarely have to look at them yourself. – Dan Pichelman Sep 04 '12 at 21:08
9

There are many advantages of using web services. The main advantage over a regular http application is that it uses SOAP messaging which is much more efficient and less bandwidth costly.

Another advantage is that Service Transport, XML Messaging, Service Description and Service Discovery layers use a standard protocol which makes it easy for developers to develop functionality irrespective of programming languages.

Suppose you are a provider of a service, say weather forecast. Why make developers, go to your website, scrap your page and then extract the data that they need? Wouldn't it be easier to develop this by web service that a developer can pass in a date and get back a well defined xml document containing all the info they need? The same happens for all type of cases...

Saani
  • 791
  • 7
  • 28
  • 68
MaVRoSCy
  • 17,747
  • 15
  • 82
  • 125
  • 1
    But aren't regular HTTP messages less bandwidth costly than SOAP? Aren't SOAP messages larger? And in the example u've mentioned, I dint get the actual adv of web-service over web-app? – Chillax Sep 04 '12 at 21:03
  • 1
    look below for Dan Pichelman comment. That is what i am talking about – MaVRoSCy Sep 04 '12 at 21:28
7

Source : Why Web Services ?

  • Exposing the existing function on to network:

A Web service is a unit of managed code that can be remotely invoked using HTTP, that is, it can be activated using HTTP requests. So, Web Services allows you to expose the functionality of your existing code over the network. Once it is exposed on the network, other application can use the functionality of your program.

  • Connecting Different Applications ie Interoperability:

Web Services allows different applications to talk to each other and share data and services among themselves. Other applications can also use the services of the web services. For example VB or .NET application can talk to java web services and vice versa. So, Web services is used to make the application platform and technology independent.

  • Standardized Protocol:

Web Services uses standardized industry standard protocol for the communication. All the four layers (Service Transport, XML Messaging, Service Description and Service Discovery layers) uses the well defined protocol in the Web Services protocol stack. This standardization of protocol stack gives the business many advantages like wide range of choices, reduction in the cost due to competition and increase in the quality.

  • Low Cost of communication:

Web Services uses SOAP over HTTP protocol for the communication, so you can use your existing low cost internet for implementing Web Services. This solution is much less costly compared to proprietary solutions like EDI/B2B. Beside SOAP over HTTP, Web Services can also be implemented on other reliable transport mechanisms like FTP etc.

KNU
  • 2,560
  • 5
  • 26
  • 39
KingFeming
  • 1,053
  • 10
  • 21
  • 3
    always give proper credit to original author unless otherwise you yourself are that author or intend to steal. source : http://www.tutorialspoint.com/webservices/why_web_services.htm – KNU Nov 19 '14 at 05:49
0
  1. It provides modularity between UI and back-end code by removing the dependencies (like JSP and JSF) of back end and UI code.

  2. The communication is more efficient and less bandwidth costly. we shares only required data using xml and json format.

  3. Now a day’s applications are used from other various devices like Mobile PDA and also, we have mobile app for most of the application. So, in this case if we use web services then we don’t need to implement application differently only we will develop the UI for different device and mobile app and call the required services.

Ritesh Kumar
  • 129
  • 1
  • 7