=================================================================
How does data exchange between applications take place?
Ans. Request and Response should be in proper formats, to support web service on different platforms
- XML
- JSON
How does Application A knows the format of Request and Response?
=================================================================
Web Service - Key Terminologies
Request: i/p to web service
Response: o/p from web service
Message Exchange Format: format of request and response
Service Provider or Server: which hosts the web service.
eg. Web Service is a service provider
Service Consumer or Client: who consumes the web service
eg. Application A, JavaApplication, DotNetApplication, PHPApplication is a service consumer.
Contract b/w service provider and service consumer.
- One, weather service is exposed on the internet i.e. HTTP.
- HTTP is over the web like we use the URL in browser similarly Application_A will call web service.
- Two, weather service is exposed over the transport which is queue i.e. MQ.
- The service requester would place a message in the queue.
- The service provider would be listening on the queue.
- As soon as there's request on the queue it would take the request, do the processing of it, create the response and put it back in the queue.
- The service requester would get the response from the queue.
- The transport will be MQ, here it is WebSphere MQ
=================================================================
Types of Web Services
- SOAP
- REST
SOAP and REST are not really comparable.
REST defines an architectural approach.
SOAP poses restrictions on the format of XML which is exchanged between your service provider and service consumer.
Introduction of SOAP Web Services
- SOAP defines a specific way of building web services.
- Here we use XML as a request exchange format.
- It defines the specific XML request and response structure.
- Format
- XML Request and Response
- Transport
- SOAP over MQ
- SOAP over HTTP
- Service Defination
- WSDL
- WSDL defines the end point i.e. where your service is exposed.
- It defines all the operations exposed
- get all codes details
- add a new course
- delete course
- Also, specifies the request and response structure.
SOAP is all about adhering to services XML structure. Adhering to envelop header and body.
Once we have your request and response in that structure, then we can say that we are developing SOAP web services.
=================================================================
Introduction to RESTful Web Service
when we enter the URL in the browser, a request is sent to the website server.
The website server responds back with a response.
What is the format of request and response?
These requests and responses are in a format defined by HTTP protocol.
In addition to request header and request body, HTTP also defines HTTP Methods and HTTL Status Codes.
Roy Fielding (who invented HTTP) said, why don't we use HTTP to develop web services.
Hence, concept of RESTful webservices came.
RESTful web services try to define services using different concepts that are already present in HTTP.
Most important abstraction in REST is something called resource.
A resource is ant thing that you want to expose to outside world through your application.
eg. in TODO Management Service
- users are resource who are using it, Let Ram is a resource.
- specific TODO is a resource
- LIST of TODOs is also a resource.
So, we define a URI for these resources.
- A resource has an URI (Uniform Resource Identifier)
- /user/ram/todos/1
- /user/ram/todos
- /user/ram
- Resources ca have different representations
- XML
- HTML
- JSON
The most important thing is the fact that you can define your resource and perform actions on these resources using whatever facilities are provided by HTTP.
EXAMPLE
- Create a User: POST /users
- Delete a User: DELETE /users/1
- Get all User: GET /users
- Get one Users: GET /users/1
REST
- Data Exchange Format
- No restriction. JSON is popular
- Transport
- Only HTTP
- Service Defination
- No Standard. WADL/Swagger










No comments:
Post a Comment