Web Services
Web services are open standard (XML, SOAP, HTTP, etc.) based web applications that interact with other web applications for the purpose of exchanging data. Web services can convert your existing applications into web applications.
Definitions:
Definitions:
- A web service is any piece of software that makes itself available over the internet and uses a standardized XML messaging system. XML is used to encode all communications to a web service. For example, a client invokes a web service by sending an XML message, then waits for a corresponding XML response. As all communication is in XML, web services are not tied to any one operating system or programming language—Java can talk with Perl; Windows applications can talk with Unix applications.
- Web services are self-contained, modular, distributed, dynamic applications that can be described, published, located, or invoked over the network to create products, processes, and supply chains. These applications can be local, distributed, or web-based. Web services are built on top of open standards such as TCP/IP, HTTP, Java, HTML, and XML.
- Web services are XML-based information exchange systems that use the Internet for direct application-to-application interaction. These systems can include programs, objects, messages, or documents.
- A web service is a collection of open protocols and standards used for exchanging data between applications or systems. Software applications written in various programming languages and running on various platforms can use web services to exchange data over computer networks like the Internet in a manner similar to inter-process communication on a single computer. This interoperability (e.g., between Java and Python, or Windows and Linux applications) is due to the use of open standards.
To summarize, a complete web service is, therefore, any service that −
Components of Web Services:
The basic web services platform is XML + HTTP. All the standard web services work using the following components −
- Is available over the Internet or private (intranet) networks
- Uses a standardized XML messaging system
- Is not tied to any one operating system or programming language
- Is self-describing via a common XML grammar
- Is discoverable via a simple find mechanism
Components of Web Services:
The basic web services platform is XML + HTTP. All the standard web services work using the following components −
- SOAP (Simple Object Access Protocol)
- UDDI (Universal Description, Discovery and Integration)
- WSDL (Web Services Description Language)
Types of Web Services:
There are two types of web services:
REST stands for REpresentational State Transfer. It is developed by Roy Thomas Fielding who also developed HTTP. The main goal of RESTful web services is to make web services more effective. RESTful web services try to define services using the different concepts that are already present in HTTP. REST is an architectural approach, not a protocol.
It does not define the standard message exchange format. We can build REST services with both XML and JSON. JSON is more popular format with REST. The key abstraction is a resource in REST. A resource can be anything. It can be accessed through a Uniform Resource Identifier (URI).
For example: The resource has representations like XML, HTML, and JSON. The current state is captured by representational resource. When we request a resource, we provide the representation of the resource. The important methods of HTTP are:
POST /users: It creates a user.
GET /users/{id}: It retrieve the detail of one user.
GET /users: It retrieve the detail of all users.
DELETE /users: It delete all users.
DELETE /users/{id}: It delete a user.
GET /users/{id}/posts/post_id: It retrieve the detail of a specific post.
POST / users/{id}/ posts: It creates a post for a user.
GET /users/{id}/post: Retrieve all posts for a user
HTTP also defines the following standard status code:
RESTful Service Constraints:
Advantages of RESTful web services:
There are two types of web services:
- RESTful Web Services
- SOAP Web Services
REST stands for REpresentational State Transfer. It is developed by Roy Thomas Fielding who also developed HTTP. The main goal of RESTful web services is to make web services more effective. RESTful web services try to define services using the different concepts that are already present in HTTP. REST is an architectural approach, not a protocol.
It does not define the standard message exchange format. We can build REST services with both XML and JSON. JSON is more popular format with REST. The key abstraction is a resource in REST. A resource can be anything. It can be accessed through a Uniform Resource Identifier (URI).
For example: The resource has representations like XML, HTML, and JSON. The current state is captured by representational resource. When we request a resource, we provide the representation of the resource. The important methods of HTTP are:
- GET: It reads a resource.
- PUT: It updates an existing resource.
- POST: It creates a new resource.
- DELETE: It deletes the resource.
POST /users: It creates a user.
GET /users/{id}: It retrieve the detail of one user.
GET /users: It retrieve the detail of all users.
DELETE /users: It delete all users.
DELETE /users/{id}: It delete a user.
GET /users/{id}/posts/post_id: It retrieve the detail of a specific post.
POST / users/{id}/ posts: It creates a post for a user.
GET /users/{id}/post: Retrieve all posts for a user
HTTP also defines the following standard status code:
- 404: RESOURCE NOT FOUND
- 200: SUCCESS
- 201: CREATED
- 401: UNAUTHORIZED
- 500: SERVER ERROR
RESTful Service Constraints:
- There must be a service producer and service consumer.
- The service is stateless.
- The service result must be cacheable.
- The interface is uniform and exposing resources.
- The service should assume a layered architecture.
Advantages of RESTful web services:
- RESTful web services are platform-independent.
- It can be written in any programming language and can be executed on any platform.
- It provides different data format like JSON, text, HTML, and XML.
- It is fast in comparison to SOAP because there is no strict specification like SOAP.
- These are reusable.
- These are language neutral.
SOAP Web Services:
REST defines an architectural approach whereas SOAP poses a restriction on the format of the XML. XML transfer data between the service provider and service consumer. Remember that SOAP and REST are not comparable.
SOAP: SOAP acronym for Simple Object Access Protocol. It defines the standard XML format. It also defines the way of building web services. We use Web Service Definition Language (WSDL) to define the format of request XML and the response XML.
For example, we have requested to access the Todo application from the Facebook application. The Facebook application sends an XML request to the Todo application. Todo application processes the request and generates the XML response and sends back to the Facebook application.
REST defines an architectural approach whereas SOAP poses a restriction on the format of the XML. XML transfer data between the service provider and service consumer. Remember that SOAP and REST are not comparable.
SOAP: SOAP acronym for Simple Object Access Protocol. It defines the standard XML format. It also defines the way of building web services. We use Web Service Definition Language (WSDL) to define the format of request XML and the response XML.
For example, we have requested to access the Todo application from the Facebook application. The Facebook application sends an XML request to the Todo application. Todo application processes the request and generates the XML response and sends back to the Facebook application.
Need More Information then Download the material!
© Copyright Protected.