Android Web Services – Architecture, Features and Types
In this Android tutorial by DataFlair, we’ll learn about Android Web Services. Before that, let us understand what Web services are. Web services are a collection of open-source protocols and standards(xml, http, etc.) that are useful for the exchange of data between systems or applications.
Do you want to become an Android Professional? Join Android Telegram Channel
What are Android Web Services?
A web service is basically required to provide interoperability, i.e. connecting various applications. It allows different apps to communicate with each other and share the data and services among themselves. Web services provide a standard for all the types of client applications to invoke functions on every type of app server.
For example, you can consider an android application interacting with a .NET app using a web service.
Provided below is the simple depiction of how a Web Server actually works. It has two important things that are the Client and the Server. Here first the Client makes a request from the Server and then, the Server makes a response to the Client.
Android Web Services Components
The web server architecture generally contains the following three roles-
The publisher can be understood as a Service provider. The publisher is responsible for creating the web service and making it available for the Clients.
The Subscriber is nothing but, the service requester. The Service requester is the one that needs to contact the web service. The client application will contact through a client application. This Client application can be based on .Net or any language based language.
The broker here is the application that provides access to the UDDI. The UDDI stands for User descriptive, discovery and integration. It enables the client application to locate the web service exactly.
The services that do are as follows:
Publishers Publishing the web services means informing the broker about its existence. It is done using the Broker’s interface to make is easily accessible to the subscribers
The Subscriber will consult the broker to locate the published web service easily .
Once the information regarding the web services is gained from the broker, the subscriber can bind the web service.
Characteristics of Web Services in Android
Before knowing more about web-services, we’ll understand some of the behavioral characteristics.
1. Web services are XML – based. They use it at its data representational layer and its transportational layer as it removes networking, operating system or even the platform binding. These services are highly interoperable at their core level.
2. Web services are loosely coupled. That means the consumer web services and providers of web service are not tied together directly.
3. Web services have the ability to be either Synchronous or Asynchronous. Here Synchronous can be understood as binding the client to the execution of the service. On the other hand, Asynchronous refers to allowing the client to invoke a service first and later executing the other functions.
4. Web Services supports Remote Procedure Calls. Remote Procedure calls can often be referred to as RPCs. These RPCs let the clients invoke various functions, methods, and services on remote objects using XML.
5. There is support to Document exchange in Web Services. In fact, XML has a very generic way to represent data as well as complex documents. Along with that, it has got various ways to represent these documents.
XML Remote Procedure Calls
Remote procedure calls are one of the finest ways for the exchange of documents and information between computers. Let us see some things about XML-RPC:
1. It uses XML messages to perform Remote Calls.
2. These requests are encoded in XML and are transferred via http POST.
3. The XML responses are embedded in the same way as http responses.
4. XML- RPC is platform-independent as well as Language independent.
5. It also allows diverse applications to communicate with each other.
6. It is developed using W3C standards.
Types of Web Services in Android
There are various types of Web Services as below:
In XML-RPC, RPC stands for remote procedure calls. It is an XML based protocol for the exchange of data between a huge range of devices over the internet.
UDDI stands for Universal Descriptive, discovery, and integration. It is an XML- based standard used for detailing, publishing and discovering new web services.
SOAP here stands for Simple object access protocol. It is an XML based web service protocol used for the exchange of data or documents over HTTP(Hypertext transfer protocol) or SMTP(Simple Message Transfer Protocol). It allows the communication of independent processes that operate on disparate systems.
Here, REST is Representational State Transfer. It provides communication and connectivity between devices and the internet.
Advantages of Web Services
Following are the advantages of Web services-
1. Web services enable interoperability among different Applications.
2. One of the very important advantages of using web services is Reusability.
3. Web services offer faster communications within and across applications and organizations.
4. They use a quality industry-standard protocol to enable communication between different applications.
5. They use SOAP over HTTP to enable the use of low-cost internet for implementing web services.
6. Web Services are deployed over the standard internet technologies.
7. They allow us to expose the functions of the existing code over the internet.
Android Web Services Limitations
There are also some disadvantages of web services as below:
1. Web services do not access from the browser.
2. They don’t leverage emerging Web developments
3. The HTTP protocol used by web services is not reliable and is insecure.
In this tutorial, we discussed the Web services in Android. Initially we read about the different types of web services and then about its advantages and disadvantages. We also learnt the components of Android web services.
Hope you enjoyed the article. Do not forget to share your feedback in the comment section.