Web Service Tutorial - Web Service Introduction

In this section we will give all introduction about Web Service Tutorial .
A web service is a method of communication between two electronic devices over the World Wide Web. A web service is a software function provided at a network address over the web or the cloud, it is a service that is "always on" as in the concept of utility computing.

The W3C defines a "Web service" as:

"a software system designed to support interoperable machine-to-machine interaction over a network. It has an interface described in a machine-processable format (specifically WSDL). Other systems interact with the Web service in a manner prescribed by its description using SOAP messages, typically conveyed using HTTP with an XML serialization in conjunction with other Web-related standards."

The W3C also states:
We can identify two major classes of Web services:
  1. REST-compliant Web services(JAX-RS), in which the primary purpose of the service is to manipulate XML representations of Web resources using a uniform set of "stateless" operations; and
  2. arbitrary Web services(JAX-WS), in which the service may expose an arbitrary set of operations.

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.

The World Wide Web Consortium (W3C) has defined the web services. According to W3C, “Web Services are the message-based design frequently found on the Web and in enterprise software. The Web of Services is based on technologies such as HTTP, XML, SOAP, WSDL, SPARQL, and others.

Why you need to learn web services?
Reuse already developed(old) functionality into new software:
Lets understand with very simple example.Lets say you are developing a finance software for a company on java and you have old .net software which manages salary of employees.So rather then developing new software for employee part,you can use old software and for other parts like infrastructure you can develop your own functionalities.

Usability :
Web Services allow the business logic of many different systems to be exposed over the Web. This gives your applications the freedom to chose the Web Services that they need. Instead of re-inventing the wheel for each client, you need only include additional application-specific business logic on the client-side. This allows you to develop services and/or client-side code using the languages and tools that you want.

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.

Some Terminologies 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.

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.

Elements of WSDL are:

It is the root element of a WSDL 2.0 file. It usually contains a set of name space declarations which are used throughout the WSDL file.

The WSDL types element describes the data types used by your web service. Data types are usually specified by XML schema.It can be described in any language as long as your web services API supports it.

The WSDL binding element describes how your web service is bound to a protocol. In other words, how your web service is accessible. To be accessible, the web service must be reachable using some network protocol. This is called "binding" the web service to the protocol.

The WSDL interface element describes the operations supported by your web service.It is similar to methods in programming language.Client can only call one operation per request.

It describes the endpoint of your web service. In other words, the address where the web service can be reached.

The endpoint element describes the address of the web service. The endpoint binding attribute describes what binding element this endpoint uses.i.e. protocol with which you will access web service. The address attribute describes the URI at which you can access the service.

The message element describes the data being exchanged between the Web service providers and consumers.

 Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.2.7-b01  svn-revision#${svn.Last.Changed.Rev}. 
 Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.2.7-b01  svn-revision#${svn.Last.Changed.Rev}. 
<definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://ws.dineshonjava.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://ws.dineshonjava.com/" name="HelloWorldImplService">
    <message name="sayHelloWorld"/>
    <message name="sayHelloWorldResponse">
       <part name="return" type="xsd:string"/>
    <portType name="HelloWorld">
       <operation name="sayHelloWorld">
           <input wsam:Action="http://ws.dineshonjava.com/HelloWorld/sayHelloWorldRequest" message="tns:sayHelloWorld"/>
           <output wsam:Action="http://ws.dineshonjava.com/HelloWorld/sayHelloWorldResponse" message="tns:sayHelloWorldResponse"/>
     <binding name="HelloWorldImplPortBinding" type="tns:HelloWorld">
         <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/>
         <operation name="sayHelloWorld">
             <soap:operation soapAction=""/>
                  <soap:body use="literal" namespace="http://ws.dineshonjava.com/"/>
                 <soap:body use="literal" namespace="http://ws.dineshonjava.com/"/>
    <service name="HelloWorldImplService">
      <port name="HelloWorldImplPort" binding="tns:HelloWorldImplPortBinding">
            <soap:address location="http://localhost:8181/sdnext/hello"/>

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.

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.

1. Types of Web Services
2. Creating a Simple Web Service and Clients with JAX...
3. Why Contract First?
4. Writing Contract First Web Service 


  1. hey, in your website. if any one wants to click on sub-menu than he or she can not go there. we can only click on the menu that is it. please fix the issue.
    for eg:- i want to click on WSDL sub menu in the web services section than I am unable to click on WSDL.

    - Dhirajkumar Rameshchand Jaiswal

    1. Hi Dhiraj,

      In which browser you got this problem?
      I think it is in IE?


    2. yes!!! In IE 9 and the big problem is we are allowed to use only IE. And one more thing I would like to suggest you is: as you are giving a knowlege of java you can also include your video sessions. And it will be Extreamly great if you can include the topic of web hosting and videos on it!!
      - Sincere Regards
      Dhirajkumar Rameshchand Jaiswal