Friday, July 29, 2016

Web services tutorial


Web service is a way of communication that allows interoperability between different applications on different platforms, for example, a java based application on Windows can communicate with a .Net based one on Linux. The communication can be done through a set of XML messages over HTTP protocol.

Web services are browsers and operating system independent service, which means it can run on any browser without the need of making any changes. Web Services take Web-applications to the Next Level.

Why you need to learn web services:

Reuse already developed (old) functionality into new software:
Let’s understand with very simple example. Let’s say you are developing finance software for a company on java and you have old .net software which manages salary of employees. So rather than developing new software for employee part, you can use old software and for other parts like infrastructure you can develop your own functionalities.

Interoperability:
This is the most important benefit of Web Services. Web Services typically work outside of private networks, offering developers a non-proprietary route to their solutions. Web Services also let developers use their preferred programming languages. In addition, thanks to the use of standards-based communications methods, Web Services are virtually platform-independent.

Loosely Coupled:
Each service exists independently of the other services that make up the application. Individual pieces of the application to be modified without impacting unrelated areas.

Ease of Integration:
Data is isolated between applications creating ’silos’. Web Services act as glue between these and enable easier communications within and across organizations.

Deployability:
Web Services are deployed over standard Internet technologies. This makes it possible to deploy Web Services even over the fire wall to servers running on the Internet on the other side of the globe. Also thanks to the use of proven community standards, underlying security (such as SSL) is already built-in.

Types of Web Services

There are mainly two types of web services.
  1. SOAP web services.
  2. RESTful web services.

Some jargons used in Web services:

Simple Object Access Protocol (SOAP):

SOAP is a protocol specification for exchanging structured information in the implementation of Web services in computer networks. It relies on XML as its message format.
A SOAP message is an ordinary XML document containing the following elements −
  • Envelope − Defines the start and the end of the message. It is a mandatory element.
  • Header − Contains any optional attributes of the message used in processing the message, either at an intermediary point or at the ultimate end-point. It is an optional element.
  • Body − Contains the XML data comprising the message being sent. It is a mandatory element.
  • Fault − An optional Fault element that provides information about errors that occur while processing the message.

Web Service Description Language (WSDL):

WSDL stands for Web Service Description Language. It is an XML file that describes
the technical details of how to implement a web service, more specifically the URI,
port, method names, arguments, and data types. Since WSDL is XML, it is both
human-readable and machine-consumable, which aids in the ability to call and bind to
services dynamically. 

WSDL Elements
A WSDL document contains the following elements:
  • Definition: It is the root element of all WSDL documents. It defines the name of the web service, declares multiple namespaces used throughout the remainder of the document, and contains all the service elements described here.
  • Data types: The data types to be used in the messages are in the form of XML schemas.
  • Message: It is an abstract definition of the data, in the form of a message presented either as an entire document or as arguments to be mapped to a method invocation.
  • Operation: It is the abstract definition of the operation for a message, such as naming a method, message queue, or business process, that will accept and process the message.
  • Port type: It is an abstract set of operations mapped to one or more end-points, defining the collection of operations for a binding; the collection of operations, as it is abstract, can be mapped to multiple transports through various bindings.
  • Binding: It is the concrete protocol and data formats for the operations and messages defined for a particular port type.
  • Port: It is a combination of a binding and a network address, providing the target address of the service communication.
  • Service: It is a collection of related end-points encompassing the service definitions in the file; the services map the binding to the port and include any extensibility definitions.
In addition to these major elements, the WSDL specification also defines the following utility elements:
  • Documentation: This element is used to provide human-readable documentation and can be included inside any other WSDL element.
  • Import: This element is used to import other WSDL documents or XML Schemas.

Universal Description, Discovery and Integration (UDDI): 

UDDI stands for Universal Description, Discovery and Integration. It is a directory service. Web services can register with a UDDI and make themselves available through it for discovery
 


SOAP Web service design approaches:

There are mainly two types of  soap web service design approaches.
Contract last or Bottom up approach:
When using contract last approach,you first write your java code then you create web service contract(WSDL) .There are various kinds of tools which can generate WSDL on the basis of java code.
Contract first or Top Down Approach :
It  is reverse of contract first.Here you first define web service contract.You define all the elements of WSDL first then after that you create your java logic.


No comments:

Post a Comment