Web Service Tutorial

In this web service tutorial, we will see the introduction of webservices in java and some jargons of web services.

Webservices in java are used everywhere nowadays. When human interacts with any web page, it involves request and response via HTML. When you interact with the webpage, browser sends a request and then renders response and shows in form of HTML. Similarly, web services also involve request and response but in the form of XML or JSON or plain text. It generally used for other applications or programs to consume and make use of information.

For example:
You are creating a website which shows weather information of important cities in the world. You can actually consume already exposed web services and get the data for the cities. You will get the response in form of XML or JSON, you can parse it and show it on your website.

Let’s go to more formal definition now:

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.

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.”
Let’s say, you are a Java developer and you can publish your functions on internet or LAN through java web service so any other developer(let’s say .Net developer) can access your function.

You can go through web services interview questions for interview questions on webservices in java.

Why you need to learn web services:

Reuse already developed(old) functionality into new software:

Let’s understand with the very simple example.Let’s 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 than 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 firewall 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 jargons used in Webservices in java:

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:

Description:
It is the root element of a WSDL 2.0 file. It usually contains a set of namespace declarations which are used throughout the WSDL file. 

Types:
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.

Binding:
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.

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

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

Endpoint:
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.

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

Sample WSDL file:

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.

Types of webservices in java:

There are mainly two types of web services.

You can read about differences and usage of REST and SOAP web services.

That’s all about the webservices in java.


import_contacts

You may also like:

Related Posts

  • 04 August

    Spring Restful web services xml example

    This post is in continuation with web service tutorial (Part -10). In this tutorial,we are going to see Spring Restful web services xml example. Web service Tutorial Content: Introduction to web services Web services interview questions SOAP web service introduction RESTful web service introduction Difference between SOAP and REST web services SOAP web service example in […]

  • 26 June

    Difference between SOAP and REST web services in java

    We have already seen SOAP web services and RESTful web services in detail before. In this post, we are going to see differences between SOAP and REST web services. SOAP vs REST web services Parameter SOAP REST Acronym SOAP stands for simple object access protocol REST stands for REpresentational State Transfer Protocol vs Architectural style […]

  • 24 June

    Top 20 Web services interview questions

    Web services interview questions are most asked questions if you are applying for software developer role. In this post, we will see multiple web services interview questions. 1. What are web services? Web services are ways of communication between two application over network. It allows you to expose business logic using API. For example: Lets […]

  • 22 June

    Restful web services interview questions

    Restful web services are very popular now a days because it is very simple to implement and less time consuming. In this post, we are going to see restful web services interview questions with answers. 1. What is REST? REST is an architectural style which was brought in by Roy Fielding in 2000 in his […]

  • 15 April

    Spring Restful web services CRUD example

    In this post, we are going see Spring Restful web services CRUD example. Web service Tutorial Content: Introduction to web services Web services interview questions SOAP web service introduction RESTful web service introduction Difference between SOAP and REST web services SOAP web service example in java using eclipse JAX-WS web service eclipse tutorial JAX-WS web service […]

  • 29 March

    RESTful web services JAXRS CRUD example using jersey

    This post is in continuation with web service tutorial (Part -8). Introduction to web services Web services interview questions SOAP web service introduction RESTful web service introduction Difference between SOAP and REST web services SOAP web service example in java using eclipse JAX-WS web service eclipse tutorial JAX-WS web service deployment on tomcatCreate RESTful web […]

Comments

  1. What's the main difference between Java and python? which one is more easy to learn? i am interested to use it for web service development.

  2. I love ur simple codes.. I refer to ur website wen i hav to begin wid a particular technology.. bt the bookish definitions dont suit ur simple website.. u cud actually explain all the definitions in a layman terms so tat its easy fr freshers lik me to learn theory as well frm ur site.. Awsome site!!! thanks!!!

    1. That’s a good compliment for me. I would really try to make the definition as simple as possible.
      Thank you. I am glad that you liked my blog 🙂

  3. Well , blog is nice.
    But i always confised about webservice.. What to write, when to write, where to write ?

  4. Your tutorial is very good. Unlike other beginners tutorials which simply show us the annotations to be used for web services, your tutorial actually gives proper explanation on each annotation. I found it very useful and easy to understand. Thanks much for posting this.

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe to our newletter

Get quality tutorials to your inbox. Subscribe now.