0:31
So what are web services?
Well, let's look at this from an example.
So say we have a movie application that has four methods like add movie, update,
delete and get movie via ID.
And this is a self contained standalone application.
And in this example we have say two classes.
Or it could be even your web tier, like HTML, Java server pages, whatever it is.
And it's making a call and getting data from these methods,
really these are methods in your application.
Now at some point, you see a value in this method saying,
hey getMovie's being used by my application, but
I do see a value in exposing this as a service to other applications.
Maybe it might start off something simple,
like maybe some other application within your own company's expecting this data.
And then you might do that way.
Or you might just see, again as I said, a value in exposing this as a service for
other clients and other companies to use.
It could be a free service, it could be a paid service.
It all depends, but the whole idea is exposing something
reusable that was self contained but now it's something more public.
So in this example, say we have these four methods that becomes more of a service.
And then what you'd do is, it's still within your application, but
you expose it as a public service.
So now it becomes part of a movie service,
which can be accessed over the Internet by pretty much anybody out there.
It's basically a web service, right?
And then a client A might come in and say, hey give me a movie with an ID.
And then client B might do some administrative things like updating
the movie or deleting the movie.
And then the other application could come in and say,
give me the list of writers and directors and roles and
other methods that you have exposed as part of the service.
So really web service is nothing but taking the simple method or
an API within your application, right?
And exposing it as a web service.
Now you can go online and find a number of free web services out there.
Some popular sites like xmethods.net or webservicesx.net.
Or you can just search online, and you'll find a number of free web services
like Stalk Service or Weather Service and Currency Exchange Service.
There's quite a few.
So the official definition of a web service,
or one of the definition is software that makes services available on
a network using technologies such as XML and JSON over HTTP, right?
So the goal is interoperability between enterprise.
So you could have two applications, one could be Ruby on Rails,
one could be Java, one could be .NET, one could be SAP.
It could be anything.
It could be a command line application making a call.
So the whole idea is interoperability between two applications, so
it's language independent, it's platform independent.
I mean, all I have is a service, right?
An end point, that's all I care about.
And I'll make a call to this endpoint, right?
I'll make a call to this service, a get request, a post request, and
we'll talk about all of this in this module.
And what you get back is some kind of a response, right?
How you've done it, how the implementation has been made, what language,
what platform, it's completely independent, right?
All you care about is that endpoint, right?
The URI, that's all you care about, right?
And yeah, it's all about request and response, we'll talk about that.
So it goes back to the classical definition of service oriented, which
is distributed collection of smaller, loosely coupled service providers.
So, really when you look at web services,
it's a collection of small, loosely coupled service providers.
So it's a loosely coupled [INAUDIBLE] and goes back to the same as platform
independent, language independent and all that.
And you have a bunch of service providers.
Here is a stock information service, a weather information service.
And all kinds of other services out there, where you just send in a request and
you get a response back from them.
So what are some of the differences between a web services versus a web
application?
So, one big difference is the fact that web services will, although XML and
JSON are the most common response types, you also
can get a wide variety of different MIME types, and we'll talk about this later on.
Like PDF and multimedia, audio, video, everything is possible.
But as web application, for the most part, it's HTML that comes back.
I mean, it might get rendered using various technologies, but for
the most part, a web application you enter the application with an HTML and
what you get back is an HTML.
And web services is program to program interaction.
So as I said, your application A will make a call to and endpoint and
get some data back.
Whereas web application is mostly user to program interaction.
So you as a user will login and go to website,
and click on some buttons, and take some action.
So, web services is mostly machine to machine or program to program.
Also web services is primarily CRUD based API, meaning it's not really a GUI based
application, there's no graphical user interface for the most part, it's an API.
And it is a machine to machine,
so you send the request and you get the response back.
Whereas web application as you all know, it's mostly in UI application.
6:30
And web services, there's a possibility of service integration,
which means you could go to one travel service.
And the travel service may go and talk to airline service, and
a car rental service, and a hotel service, and
kind of put everything together and give you back the data.
While web application can also do that,
the web application itself is a monolithic service,
meaning it's one web application deployed on a web application container.
Now the web application, like Travelocity or whatever website you're going to,
will or might access other services under the cover.
So basically they will go and
talk to web services like hotel service and car rental service and all that.
But the application itself, the web application itself is this Java based or
whatever the language that you can pick.
It's one application that's deployed, which again,
internally could be calling multiple services.
So let's take our basic movie application example.
Now we will be doing this live in an upcoming lectures with our movie example.
The really idea behind a web service, now that we know some basic concepts.
So you have a client and you have a movie service.
And there is a predefined contract, so to speak,
meaning you know all the different APIs.
The endpoint and you know what is the request you need to send.
What responds will you get back.
What are all the different options you have.
Like, get movies, get actors, get directors, get writers.
And you can get a movie by ID, director by ID.
So this is,basically,what mean by contract.
You know what are all.
So, typically if you go to Netflix API or IMDB API or any of these sites,
you have a documentation that has all of this information.
So, once you know all the different service options that you have,
you can make a request.
So in this example, I'm showing you a GET request.
So you would do a GET movie by ID, and
then the movie service will come back with a response.
Now, there is obviously a whole authentication factor here.
So if it's a paid service, then you will have login and password and
all that information also that will be sent across.
We won't get into that now.
8:56
So once again, once that has all been established it's a simple GET request and
you get a response back.
And then there's a post, there's a put, there's a delete, there's a patch.
There's the h-e-a-d head request.
There's all these different things,
which we will talk about in the upcoming lectures.
Well, so here are some of the popular sites.
Just a handful of this sites using web service extensively.
And many of these also provide web services API for the clients or
for users to use, like Twitter, Netflix, Pandora, Amazon, Google and so on.
But again, you can go up and look and read about all of these, or
any other additional services from other companies out there.
because their extremely common in the industry to use, or
exposed services as basically web services.
So just to summarize, a web service is just an endpoint or
an interface for a consumer to request data, request information.
Now, the consumer is typically an application, unlike a web app where
the consumer, meaning it's not you as a user going into a web application.