35 WEB SERVICES – I

Dr S. Abirami

WEB SERVICES – I

 

Learning Objectives:

 

This module is intended to learn about the fundamentals of web services, different types of web services and to understand about the architecture of web services along with its implementation.

  1. Overview of DISTRIBUTED COMPUTING TECHNOLOGIES

To know/understand the basics of web services, an overview of various distributed computing technologies has been discussed here

 

CORBA (OMG) : It is standards-based, vendor-neutral, and language-agnostic middleware. This is very powerful but limited by its complicated way of utilizing the power and flexibility of the Internet.

DCOM (Microsoft): This is a Distributed Computing platform which is closely tied to Microsoft components such as OLE, COM and ActiveX.

RMI (Sun Microsystems):This kind of middleware is purely Java based effort which doesn’t play well with other languages. This is an J2EE platform integrated RMI with IIOP.

Web Services (W3C): In this series, Web services are more of an evolution than a revolution .

  1. INTRODUCTION TO WEB SERVICE

Figure 1. shows an environment where data need to get shared between devices in a networkwhich uses a standard web protocol like HTTP in addition to the servers, browsers, firewall, security and databases.Here, HTTP is supported by all Web Browser, Servers and many Programming Languages Today. But an ideal solution which can support all of these entities in a real time environment is Web Services. Because Web services uses standard web protocols like HTTP and it is supported by all servers, browsers and PL’s.

 

 

A web service is a network accessible interface to application programs, built using standard Internet technologies as shown in Figure 2. Clients of web services do not need to know how it is implemented.

 

   3.Web ServicesHistory

 

Web services are evolved from previous technologies that served the same purpose such as RPC, ORPC (DCOM, CORBA and JAVA RMI) etc.Web Services are intended to solve three main problems such as interoperability, firewall traversal and complexity.

 

Firewall traversal: The collaboration across corporations was an issue because distributed systems such as CORBA and DCOM used non-standard ports. Web Services use HTTP as a transport protocol and most of the firewalls allow access though port 80 (HTTP), leading to easier and dynamic collaboration.

  Complexity: Web Services is a developer-friendly service system. Most of the above-mentioned technologies such as RMI, COM, and CORBA involve a whole learning curve.New technologies and languages need to be learnt to implement these services.

 

A more precise definition of web service can be stated as an application component that:

  • Communicates via open protocols (HTTP, SMTP, etc.)
  • Processes XML messages framed using SOAP
  • Describes its messages using XML Schema
  • Provides an endpoint description using WSDL
  • Can be discovered using UDDI
  1. WEB EVOLUTION

 The evolution of web technology has been projected in the table below (Table 1): Table 1. Evolution of Web Technologies

 

 

As a result of the evolution of web technologies, two main types of Web Services have been emerged. They are 1. SOAP based web services and 2. RESTful web services.

 

5. Web Services Advantages

 

The advantages of Web Services are listed below:

  • platform-independence
  • reusability
  • interoperability
  • scalability
  • adaptability

  6. Web Services Implementation:

There are four major web service components apart from XML Technologies. They are listed below:

  • XML
  • SOAP
  • UDDI
  • WSDL

   • XML – eXtensible Markup Language – This is a uniform data representation and exchange mechanism used for data transfer.

• SOAP – Simple Object Access Protocol – This protocols helps for a standard way for communication.

•  UDDI – Universal Description, Discovery and Integration specification – This is a mechanism which is used to register and locate Web Service based application.

•  WSDL – Web Services Description Language – A standard meta language which is used to describe the services offered.

 

Before learning about the significance of web services and its architecture, let us have an

 

overview of XML technologies. A brief description about XML has been studied in the earlier modules itself. To have a glimpse, XML is a collection of extensible information representation and manipulation language. XML itself is a base document standard. XML Schema is used for data typing and document structuring. XSLT is used here for transforming XML to other XML or other formats. XML Parsing strategies are used for XML document processing. There are two ways to parse an XML document either using XML DOM – Document Object Model or SAX parser – Simple API for XML. Apart from that, XML consists of XPATH and XQUERY languages to query the XML document.

 

 

7. Working of a Web Service

 

To initiate a web service, the client sends a requestand searches the UDDI registry/ Web service Registry for the availability of a particular web service. Once it is available in UDDI, it fetches and reads the WSDL of that service. Then it contacts the corresponding server(Publisher) which provides that service by sending a SOAP message consisting of clients request. The listener on the other hand executes the particular service requested and sends the results back to the client(Consumer). The entire flow of web service process has been shown in the figure 3.

 

  1. WEB SERVICES ARCHITECTURE

The simplest Web service system has two participants which includes a service producer (provider) and a service consumer (requester).The provider presents the interface and implementation of the service, whereas the requester uses the web service as shown in figure 4.

 

 

Web Services architecture also called as Service Oriented Architecture is a more sophisticated system where a registry, acts as a broker for Web services.A provider publishes services to the registry and the consumer discovers services in the registry as shown in the figure 5.

 

  9. Web Services Components

 

 Let us have an overview of the two important Web services components in this section. 1. SOAP and 2. WSDL. 

 

9.1 SOAP (Simple Object Access Protocol)

 

This is a standard way used for communication. SOAP is an industry accepted W3C specification for a ubiquitous XML distributed computing infrastructure. SOAP is a mechanism for defining the unit of communication and for error handling. It is an extensibility mechanism that lives above the transport layer of OSI. It is a mechanism that allows the transmission of XML documents, regardless of transport layer protocol.

  • SOAP defines some key functions needed in a distributed computing environment, namely:
  • One-way stateless message exchange mechanism.
  • Message processing model (roles, must-understand, intermediary) for SOAP nodes
  • Abstract, structured message definition which is able to run on different serializations
  • Definition of bindings to transport protocols (HTTP for firewall traversal, SMTP) is possible.
  • Extension mechanism through header elements enabling functionality defined in different XML namespaces such as WS-addressing
  • Fault handling model

   9.1.1 SOAP Messages (Logical & Physical Structure):

 

Regarding the structure of SOAP messages, the root element of a SOAP message is the Envelope element.It contains an optional Header element and the required Body Elements called Faults which are used to describe the exceptional situations.This can also contain optional Attachments in MIME encoding for exchanging binary data. The format of SOAP Envelope and attachment (SOAP message) is shown in the figure 6.

 

   

9.1.2 SOAP Example

 

Structure of a real XML based SOAP message example has been given below:

<?xml version=”1.0″ encoding=”UTF-8″?>

<soap:Envelope

soap:encodingStyle=”http://soap.org/soap/encoding/”xmlns:xsd=”http://www.w3.org/2001/XMLSchema” xmlns:soap=”http://xmlsoap.org/soap/envelope/” xmlns:xsi=”http://www.w3.org/2001/XMLSchema-inst”>

<soap:Header>

<!– Transactions, priorites, etc. –>

</soap:Header>

<soap:Body>

<!– Some content –>

</soap:Body>

</soap:Envelope>

    9.1.3 SOAP Message Transmission

 

In the process of transmission, SOAP Message Transmission involves three main roles as shown in the figure 7:The SOAP Sender creates and sends a SOAP Message to an ultimate SOAP Receiver.One or more optional SOAP Intermediaries can be positioned to intercept messages between the sender and the receiver. They can perform filtering, logging, catching etc.The  SOAP  sender’s  intended  destination  is  called  the  Ultimate  SOAP Receiver.

 

  9.2 UDDI (Universal Description, Discovery and Integration specification): This is a registry based mechanism which is used to register and locate Web Service based application.

 

9.3 WSDL (Web Services Description Language):A standard meta language which is used to describe the services offered. Web Services Description Language (WSDL) is an XML-based language for describing about web services and how to access them. WSDL was developed jointly by Microsoft and IBM. WSDL is an XML based protocol which is used for information exchange in decentralized and distributed environments. This is the standard format used for describing a web service. WSDL definition  describes  how  to  access  a  web  service  and  what  operations  it  would perform. This is also used for describing how to interface with XML-based services and it is an integral part of UDDI, an XML-based worldwide business registry.WSDL is the language that UDDI uses and is pronounced as ‘wiz-dull’ and spelled out as “W-S-D-L”.

   9.3.1 Major WSDL Elements:

 

The major elements of the WSDL with its description has been defined below. The physical and logical aspects of WSDL elements has been shown in the figure 8.The major WSDL elements encompasses the top level XML element known as the definitions element.<definitions> . . . </definitions>In addition to definitions, services are defined using eight major elements as listed below:

  •  Types: Data type definitions which is used to describe the messages exchanged.
  •  Message:The abstract definition of the data being transmitted in a message. 
  •  Parts: Each of which has one of the defined types.
  •  Operation: Each operation can have an input message and an output message.
  •  Port type: A set of operations.
  •  Binding: It specifies concrete protocol and data formats for the operations and messages defined by a particular portType.
  •  Port: Specifies an address for a binding, thus defining a singlecommunication.
  •  Service: It isused to aggregate a set of related ports.

 

The main structure of a WSDL document looks as below:

 

<definitions>

<types>  data type definitions…….. </types>

<message>

definition of the data being communicated….

</message>

<portType>  set of operations…… </portType>

<binding>protocol and data format specification….

</binding>

</definitions>

  1. Web Service Stack

Web service stack is a set of standards for which is used for implementing web services. As discussed above in the web service components, web service stack consists of 4 layers as shown in the figure 9. The top most layer UDDI extends from URI which is used for publication and discovery of web services. The third layer of the stack corresponds to the WSDL file extends from HTML used for describing the web services for better access. The second layer of the stack corresponds to the SOAP message exchanged between the consumer and the publisher and the lower layer of the stack corresponds to the the different transport protocols used.

 

11.  Basic Web Service Usage Scenario

 

Once again , a basic web service usage scenario has been illustrated using the figure 10. In this scenario, first the WSDL file is registered manually. The request is sent by the web service lookup to the web service respository (UDDI) using http get method to get the WSDL file. Then using the WSDL file description the client application is written  and it is deployed. Once the application is deployed, the application communicates with the service provider using SOAP request and receives a SOAP respose.

 

     Scenario 12. Web Service Applications

 

Application Server (web service-enabled)provides implementation of services and exposes it through WSDL/SOAPimplementation in Java, EJB, .NET (C#) environments etc.Here, SOAP server implements the SOAP protocol. The SOAP clientimplements the SOAP protocol on the client site.

 

Summary

 

This module has described about the fundamentals of Web services and various types of Web services. This module also discussed about the architecture and components of web services. We have also learnt about the implementation of the Web services.

 

Web Links

  • https://www.cs.colorado.edu/~kena/classes/7818/f06/lectures.html
  • http://www.java4s.com/web-services/
  • https://www.cl.cam.ac.uk/~ib249/teaching/Lecture1.handout.pdf
  • https://www.w3schools.com/xml/xml_services.asp
  • https://www.javatpoint.com/web-services-tutorial
  • https://www.cs.colorado.edu/~kena/classes/7818/f08/lectures/lecture_4_netbeans_presenta.pdf
  • http://vhost3.cs.rit.edu/project_web_page/webservices.html
  • http://cs.ulb.ac.be/public/teaching/infoh511
  • https://www.fas.harvard.edu/~cscie259/distribution/lectures/1/lecture1.pdf
  • http://www.java2blog.com/2013/03/web-service-tutorial.html
  • David Chappell and Tyler Jewell, “Java Web Services”, First Edition, O’Reilly, 2002
  • Paul J. Deitel, Harvey Deitel, “Java How to Program”, Ninth Edition, Pearson,2012.