What Are Web Services? Architecture, Types, Example
What Are Web Services? Architecture, Types, Example
<message name="TutorialResponse">
<part name="TutorialName" type="xsd:string"/>
</message>
<portType name="Tutorial_PortType">
<operation name="Tutorial">
<input message="tns:TutorialRequest"/>
<output message="tns:TutorialResponse"/>
</operation>
</portType>
<output>
<soap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="urn:examples:Tutorialservice"
use="encoded"/>
</output>
</operation>
</binding>
</definitions>
The important aspects to note about the above WSDL declaration are as follows;
o <message> - The message parameter in the WSDL definition is used to
define the different data elements for each operation performed by the web
service. So in the example above, we have 2 messages which can be exchanged
between the web service and the client application, one is the "TutorialRequest",
and the other is the "TutorialResponse" operation. The TutorialRequest contains an
element called "TutorialID" which is of the type string. Similarly, the
TutorialResponse operation contains an element called "TutorialName" which is
also a type string.
o <portType> - This actually describes the operation which can be
performed by the web service, which in our case is called Tutorial. This operation
can take 2 messages; one is an input message, and the other is the output
message.
o <binding> - This element contains the protocol which is used. So in our
case, we are defining it to use http (http://schemas.xmlsoap.org/soap/http).
We also specify other details for the body of the operation, like the namespace and
whether the message should be encoded.
Universal Description, Discovery, and Integration (UDDI)
UDDI is a standard for describing, publishing, and discovering the web services that
are provided by a particular service provider. It provides a specification which helps
in hosting the information on web services.
Now we discussed in the previous topic about WSDL and how it contains
information on what the Web service actually does. But how can a client application
locate a WSDL file to understand the various operations offered by a web service?
So UDDI is the answer to this and provides a repository on which WSDL files can be
hosted. So the client application will have complete access to the UDDI, which acts
as a database containing all the WSDL files.
Just as a telephone directory has the name, address and telephone
number of a particular person, the same way the UDDI registry will have
the relevant information for the web service. So that a client application
knows, where it can be found.
Web Services Advantages
We already understand why web services came about in the first place, which was
to provide a platform which could allow different applications to talk to each other.
But let's look at some other advantages of why it is important to use web services.
o Exposing Business Functionality on the network - A web service is
a unit of managed code that provides some sort of functionality to client
applications or end users. This functionality can be invoked over the HTTP protocol
which means that it can also be invoked over the internet. Nowadays all
applications are on the internet which makes the purpose of Web services more
useful. That means the web service can be anywhere on the internet and provide
the necessary functionality as required.
o Interoperability amongst applications - Web services allow various
applications to talk to each other and share data and services among themselves.
All types of applications can talk to each other. So instead of writing specific code
which can only be understood by specific applications, you can now write generic
code that can be understood by all applications
o A Standardized Protocol which everybody understands - Web
services use standardized industry protocol for the communication. All the four
layers (Service Transport, XML Messaging, Service Description, and Service
Discovery layers) uses well-defined protocols in the web services protocol stack.
o Reduction in cost of communication - Web services use SOAP over
HTTP protocol, so you can use your existing low-cost internet for implementing web
services.
Web service Architecture
Every framework needs some sort of architecture to make sure the entire
framework works as desired. Similarly, in web services, there is an architecture
which consists of three distinct roles as given below
o Provider - The provider creates the web service and makes it available
to client application who want to use it.
o Requestor - A requestor is nothing but the client application that needs
to contact a web service. The client application can be a .Net, Java, or any other
language based application which looks for some sort of functionality via a web
service.
o Broker - The broker is nothing but the application which provides access
to the UDDI. The UDDI, as discussed in the earlier topic enables the client
application to locate the web service.
The diagram below showcases how the Service provider, the Service requestor and
Service registry interact with each other.
o Publish - A provider informs the broker (service registry) about the
existence of the web service by using the broker's publish interface to make the
service accessible to clients
o Find - The requestor consults the broker to locate a published web
service
o Bind - With the information it gained from the broker(service registry)
about the web service, the requestor is able to bind, or invoke, the web service.
Web service Characteristics
Web services have the following special behavioral characteristics:
o They are XML-Based - Web Services uses XML to represent the data at
the representation and data transportation layers. Using XML eliminates any
networking, operating system, or platform sort of dependency since XML is the
common language understood by all.
o Loosely Coupled – Loosely coupled means that the client and the web
service are not bound to each other, which means that even if the web service
changes over time, it should not change the way the client calls the web service.
Adopting a loosely coupled architecture tends to make software systems more
manageable and allows simpler integration between different systems.
o Synchronous or Asynchronous functionality- Synchronicity refers to
the binding of the client to the execution of the service. In synchronous operations,
the client will actually wait for the web service to complete an operation. An
example of this is probably a scenario wherein a database read and write operation
are being performed. If data is read from one database and subsequently written to
another, then the operations have to be done in a sequential manner.
Asynchronous operations allow a client to invoke a service and then execute other
functions in parallel. This is one of the common and probably the most preferred
techniques for ensuring that other services are not stopped when a particular
operation is being carried out.
o Ability to support Remote Procedure Calls (RPCs) - Web services
enable clients to invoke procedures, functions, and methods on remote objects
using an XML-based protocol. Remote procedures expose input and output
parameters that a web service must support.
o Supports Document Exchange - One of the key benefits of XML is its
generic way of representing not only data but also complex documents. These
documents can be as simple as representing a current address, or they can be as
complex as representing an entire book.
Next