I am new to Web development. And hence, if the question is dumb, please be polite. For creating my application, I had to take a decision of whether writing a web service or a web application. After searching a few questions in stackoverflow, I came to know that, web service is something which doesn't involve human interaction. And web application is what human uses ( the UI/web page kind of stuffs ).
But lately, I saw gmail is a web service ( email service ). But I was confused from here on, because, gmail provides a UI, and human interactions do occur. And from there on, I got confused again.
So what I figured out from this is, gmail website is like a web application for users to use directly. The web application in turn uses the web service provided by Google for email. Is my understanding right? So can a web application be a client for web service?
If I am wrong somewhere, please do correct me. I hope to be clear after someone throws light on this with some good example. Thanks in advance.
You are quite right. Basically a Web Service has several endpoints over HTTP (normally) that provides data (generally in JSON or XML) and are meant to be consumed by Web Clients. Sometimes the are also called Web API's (Application Program Interface).
A Web Application is quite similar to a Web Service but it provides an interface where the user can interact with. Usually Web Applications are consumers of Web Services or Web APIs.
Following your example, Google email is could be considered as both, a Web Service and a Web Application. It is a Web Service because it provides a set of HTTP endpoints that works independently of its Web UI Application (GMail). In fact, you can find third party Web Apps that interact with the Google email Web API.
This concept is very important when designing Web Solutions. Ideally you want to design and implement a good Web API, usually a RESTful Service (in JSON/XML). Then you or others will be able to implement different types of applications (Web, Mobile, etc.) because of this API.
Related
I have searched a lot upon internet but still i didn't get the clear difference between web services and web APIs? Somewhere I read that all web services are API's but all API' are not web services. How?
What all I know is both allow to utilize the functionality of other applications.Can someone describe me clear difference?
I have been on the same journey to learn the differnce between Web API (not JUST API) vs Web Services.
First, we know for a fact that both use the Web as the communication tool as stated by #Kris.
While looking at these 2 videos, both serve as the "middleman" (the waiter in the restaurant) for a client to ask a Web Server to process and deliver a response.
Web Service (From 0:35)
API (In general) (From 1:12)
When I was looking for an actual differnce between the two, usually most articles and videos go on an unrelated comparison between "Web Services vs API" as they exclude the "Web" out of "Web API".
See this article, for example, which contains the title "Web API Vs Web Service...." yet, contain sub-titles like:
"Differences of API vs Web Service"
"Pros and Cons of Web Services vs API Service"
"Web Service vs API: Fueling Both With Scraping Robot’s API"
The only difference I could find is if we were to discuss this in .NET context.
Here's a question post related to this.
To sum it up, Web Services are used in the SOAP protocal while Web API is usually created in the RESTful way. The more detailed answers are in the post but ultimatelly do not answer the main question that is asked.
Conclusion: The question raised in the public domanin has no clear definition to what is difference between the two, thus the 2 terms are ,for the most part,
interchangeable
All web services are APIs. An API is an Application Programming Interface. But there are offline APIs, which are not web services. There are APIs for all things from Office to Websites. The API is just a defined interface to be able to control/communicate with some software. Web Services just provide that means of connecting over the web.
There is more to discuss when you are talking about APIs which are communication protocols and data formats, but you get the basic idea.
An API (Application Program Interface) is the interface through which another program can communicate with a program.
A web service in this context is one of those programs with an API. 'Web' means that it is accessible via the web, mostly via HTTP. A service usually has a well defined purpose.
For instance a date web service's purpose could be to provide the current date. The API of my service would have a single 'endpoint': get the date. The service then implements this API. It somehow retrieves the date and sends it back.
I just started learning web services. In bottom up approach, I have found some examples without being deployed in any application server. I mean a standalone web service application.
Here is an example of such type.
I have also given a try and done a walk-through of deployable simple web service examples.
So far to my learning of web services, I got to know that firstly, bottom-up- approach is not recommended. Now, in bottom-up approach, this standalone web service. When is it applicable to follow standalone web service procedure?
Endpoint.publish();
I guess, this approach is provided just for beginners and not to follow as a real-time practice. Is my interpretation correct?
I would make my application as a standalone web service if it will have multiple clients like:
Web Client via a web browser
Mobile App Client
Desktop Client
Then I could build every one of them alone using whatever the technology I prefer, and make it consumes my standalone web service.
For example, You could imagine the guys behind Twitter started developing it by building their core system as web service, then they build an independent web interface application for it, then they built the Twitter Android and iPhone APP, and another one came and introduced a Twitter Desktop client like Tweetbot and TweetDeck ... etc
my issue is about web services and all the stuff around that. I've developed a java web app, using hibernate (to connect with a mysql DB), jsf and primefaces. The only thing I have to show to the user is the index.xhtml which will search a data in a database. All of this is running on my PC with my local apache server.
But a doubt comes to my mind when I wonder if I deploy this web app in the apache server of the company, do we need something such as a web service o something like that o they just can access to the index.xhtml and start the queries?
Sorry for this but I'm totally new repesct web services, web app, web server and all these stuff.
PS. So, when do we use web services? and web server?
Thanks in advance :)
A web service is typically used as an API that might be integrated into another application. For example, if you have a way to accept payment information. You could make that a web service that would let some other application (e.g. an auction site) make calls into your web service to do some work.
Think of it a bit like a DLL that is accessible on the web. It won't have an interface, it is a collection of methods that either return data or execute some code. It will not return a UI.
So when you use a web service would be a similar question to when you need to break code out into a separate assembly.
On your specific question above, you would not need a web service, if your web application is doing everything you need it to do, then all you need is a 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
I am familiar with SOAP web services, and have done some PUT/GET/POST verbs in REST web services. Somewhere I read that your REST web service can return a code if something goes wrong at the web service, but can it return twice?
By that I mean: supposed your REST web service is querying a database and it is doing a lazy load, so it is taking a while. You intend to return an array of values from the database back to the client that called the REST web service. But while the REST web service is working on your database query, can it return a string that says "Query is 10% complete, please wait" or something like that? Can the REST web service call another web service that somehow communicates back to the client this information?
I doubt this is possible, otherwise I would have seen it, but I ask anyway.
Target platform is Visual Studio 2010 Professional with C# and MS Sql Server 2008
You could look at COMET, which according to wikipedia:
...is a programming technique that enables web servers to send data to the client without having any need for the client to request it. It allows creation of event-driven web applications which are hosted in the browser.
There are a number of articles on the web about doing this plus a couple of frameworks on sourceforge and github. However this is not trivial. I know it is possible with REST because a previous employer of mine has several real-time feeds based on RESTfull endpoints using COMET for push.
See here:
http://www.aaronlerch.com/blog/2007/07/08/creating-comet-applications-with-aspnet/
http://sourceforge.net/projects/emergetk/
https://github.com/Oyatel/CometD.NET