A web service is a standardized communication medium between a server and the client on the internet. Being a software module, it performs specific kinds of tasks. In cloud computing, web services are used to provide various functionalities when invoked by a client.
In this article, we introduce the basic concepts surrounding web services:
How Web Services Work
The figure above shows a typical web service at work. The client computer invokes various calls as requests to the server that hosts the web service.
The process of making requests is called remote procedure calls (RPC). RPC targets the host of a web service and calls specific methods.
An example of a web service is amazon.com, an online store for selling products. The client can be accessing the web service using a .Net or Java user interface, and both of the interfaces can communicate with the web service.
Transfer of data between client and server applications happening in the form of XML (Extensible markup language) documents is the major design concept of web services.
XML is easy to understand just as HTML and many programming languages understand it. It provides a platform of communication for applications developed using different programming languages.
To exchange the XML data between systems or applications, the Simple Object Access Protocol (SOAP) is used. According to Gudgin, the XML document being transferred from a web service to the client is the SOAP message.
This makes it possible for clients written in different languages to exchange data with the web service because a soap message is written in XML.
The Need for Web Services
The evolution of the internet has seen the integration of modern web-based applications into business operations. The applications are written in a variety of programming languages e.g. Java, .Net, Angular JS, Node.js, etc.
This becomes a nightmare for different applications to communicate accurate information. This gave the rise to web services that enable communication between applications built in different programming languages.
For everything to be in place, web services must meet some minimum requirements. This is irrespective of the programming language the application is written. Let us take a look at the individual components:
1. SOAP (Simple Object Access Protocol)
SOAP is known for transporting XML data in the form of SOAP Messages. It is an independent transport protocol. An XML document follows a specific structural pattern.
The most interesting part of sending SOAP messages and web services is that all happen via HTTP (the standard web protocol).
Elements of a SOAP message
<Envelope> the root element in an XML document. It is further divided into two parts:
header – contains routing information, i.e the client destination to receive the document
Body – holds the actual message
The figure below shows a simple example of SOAP communication
2. WSDL (Web Services Description Language)
A web service existence must be known before requesting a service. If a service is not found, it cannot be used. The client should further be aware of what the service does to invoke the appropriate web service.
A WSDL document describes the services offered by a web service. This enables a client to find a service and invoke the right method.
The following are aspects to note about WSDL:
<message> in the definition of WSDL, this parameter defines the different data elements for each web service operation. In the example displayed in the figure above, two messages are being exchanged between the applications i.e “DetailsRequest’ and ‘DetailsResponse” operations. The DetailsRequest contains the ‘DetailsID’ element which is a string type. Likewise, the DetailsResponse contains the ‘DetailsName’ element of string type.
<portType> this element defines the operation which can be done by a webs service, in this case, Details. It takes an input and output message
<binding> the protocol to be used is contained in this element. Other details such as whether the message should be encoded and namespace can be declared in this element
3. Universal Description, Discovery, and Integration
Contains the accepted rules for discovering, describing, and publishing web services provided by a specific web service provider. It defines particulars that help in hosting web service information.
In the previous section, we discussed that WSDL contains information about what a web service does. The question remains how a client computer can locate a WSDL file and read the contents.
This is answered by the UDDI, which acts as a database for hosting WSDL files. So the client can access the WSDL file through the UDDI.
The UDDI can be compared to a phonebook directory that contains an individual’s name, contact, address. Similarly, UDDI will have relevant information regarding a web service so that a client can access the WSDL and understand all the operations offered by a server.
In the previous sections, we have discussed why web services came into play in the first place, which is to enable applications written in different programming languages to communicate with each other.
Now let us look at the benefits of using web services:
Taking business operations to the internet. A web service provides functionalities to client applications via HTTP, which means that it can be accessed from anywhere on the internet. Businesses that have taken their operations online are finding web services very useful in providing the functionality required.
Enhanced communication. Web services have enabled applications written in different programming languages to communicate and exchange data between themselves. A generic code understood by all applications is used rather than a platform-specific code which is understood by only a specific application.
A common protocol is understood by everyone and helps communication of applications. All the layers in the protocol stack of services understand known protocols.
Efficiency in communication. Web services can be implemented using low-cost internet because they use SOAP over HTTP for communicating.
Each framework has a set of components that work together to get the desired result. Similarly, the following components are present in web service architecture:
Provider – Builds the web service and making it work for a client looking for the service
Service requestor – An application on the client-side that needs to use functionality offered by a web service. The client application can be written in any programming language but still be able to communicate with the server application.
Broker – This is no more than the application granting the client application access to the UDDI. The client will locate the web service and read the WSDL file.
Publish – A provider makes available the service to all clients who are using the broker’s interface for publishing and informs the broker about the web service existence
Find – The service requestor tries to find a published web service through the broker
Bind – Requestor can do web service invocation using information gained
Characteristics of Web Services
Web services have unique features in their behavior as follows:
Web services are XML based, that is they use XML to transport and represent data in the transportation and representation layers respectively. XML eliminates the need for an operating system, networking features, and any sort of platform dependency since all programming languages understand XML.
Loosely coupled, meaning that the web service and client applications have no relation whatsoever. In other words, if the web service changes over a given time, the process a client calls the web service should not change. Loosely coupled architecture adoption has made it easier to manage software systems and integrate them with others.
Synchronous or asynchronous functionality – Synchronous is the state when a client is bound to particular service execution. A client waits for a particular web operation to finish before another begins. For example, in databases is when performing a read and write operation, where data is read from one database and written onto another. Asynchronous operations, on the other hand, allow a client application to execute other functions in parallel after invoking a service. This is probably the most used technique today which ensures that other services don’t stop while carrying out particular operations.
Support for (RPCs) Remote Procedure Calls– To enable method or function invocation on remote objects by client applications, an XML-based protocol is used. The remote functions expose input or outputs supported by a web service.
Support for document exchange – The generic way of representing complex documents and data using XML is of great benefit. From simple documents to an entire book, XML perfectly represents the data.
A Web Service use Case
This section gives more insight into web services using a travel agent scenario. The agent is looking to offer booking capabilities of complete vacation packages: bus tickets, train, plane, hotels, excursions, car hire, etc.
Service providers (hotel chains, bus companies, airlines, etc.) avail web services to clients to make reservations. Financial companies are playing their part to guarantee payments by providing a large number of payment web services and make a coin from each transaction.
The consumer can then make a reservation from a large variety of options available. In this case, the user interacts with machines only in the process of making a booking.
The customer’s goal is to find the best combination of services and needs that suit their wants.
The travel agent hopes to meet customer demands by supplying various packages that the customer can compare.
The service providers aim at increasing product sales as much as possible.
The credit card companies guarantee their clients of making their payment services available when needed
This usage scenario describes how a developer would make the service available and how a user can make a booking of a package.
For this scenario to be practical, some requirements must be met:
Each step must be highly reliable for profitability
The services must trust each other for such a partnership
Providers must describe how to interact with their web services to achieve the desired output.
For most of such transactions, the WSDL file is in the WSDL primer
Steps a user takes to make flight destination inquiries
The user fills a form providing details about travel destination and dates
The user submits the details to find out flight schedules
The travel agent service looks for flights in the list of services it has
The agent presents the requests for available flights to meet the user needs
The agent presents the results to the user for them to make the best decision
Steps for choosing a flight and finding a hotel
The user communicates flight choice to the agent service
A request is sent to the airline service to withhold the seat
Airline responds with a confirmation identifier
The agent service searches its hotels’ catalog
The agent looks for accommodation options for each hotel and payment services available
The agent service then presents the results to the user allowing them to make the best choice
Steps to book a flight and hotel
The user informs the travel agent of their accommodation preferences
The travel agent service informs the payment service of the user’s choice to make a payment
books a hotel
Confirms the flight
Charges a user some fees
Presents to the user identity confirmation details
Before the introduction of web services, there was no streamlined exchange of data among the various technologies, business to business (B2B) operations, or vendors.
The evolution of web services has seen interoperability and system integration in the digital landscape. Today, web services provide a platform for less complexity and more functionality.
Acodez is a renowned web development company and web application developmentcompany in India. We offer all kinds of web design and Mobile app development services to our clients using the latest technologies. We are also a leading digital marketing company providing SEO, SMM, SEM, Inbound marketing services, etc at affordable prices. For further information, please contact us.
Looking for a good team
for your next project?
Contact us and we'll give you a preliminary free consultation on the web & mobile strategy that'd suit your needs best.
Jamsheer K, is the Tech Lead at Acodez. With his rich and hands-on experience in various technologies, his writing normally comes from his research and experience in mobile & web application development niche.