Java Web Services Tutorial
Here in this java web services tutorial you will learn about various concepts of web services and how to create web services in java.
What is Web Service?
Web Services are used for communication and exchanging information between applications.
In simple words, a service that is available on internet and can be invoked by client using some web protocols is called web service.
Why we need Web Services?
Let’s take one real life example to understand this.
Suppose there are two ATMs, A1 and A2 of two different banks B1 and B2. These two ATMs are using respective databases for accessing customer’s information. So the customer of bank B1 can withdraw money from ATM A1 while customer of bank B2 can withdraw money from ATM A2.
Can customer of bank B2 withdraw money from ATM A1? The answer is no. Because ATM A1 is not authorized to directly access the customer’s information from database of bank B2.
This problem can be solved easily using web service. The bank B2 will provide a web service and using it any other bank’s ATM can access their customer’s information.
Using web services, an application running on one platform can communicate with another application running on different platform. Interoperability is the biggest feature of web services.
In above figure you can see that a Java application can easily communicate with PHP or .Net application with the help of web services.
Let’s try to understand some basic terminologies used in web services.
SOAP stands for Simple Object Access Protocol.
It is a XML based standard protocol that is used for accessing web services.
It is language and platform independent.
REST stands for Representational State Transfer.
It is an architectural style used for developing web services.
WSDL stands for Web Service Description Language.
As its name suggests, it is used for describing the web services. Clients use it to get information about web services.
It is a XML document that contains information about web service like method name, parameters name and type, method return type, etc.
UDDI stands for Universal Description, Discovery and Integration.
UDDI is a XML based framework for describing, discovering and integrating web services.
Clients get access to WSDL using UDDI registry.
HTTP stands for Hypertext Transfer Protocol.
It is used for sending message request from client to web service and message response from web service to client.
Types of Web Services
Web Services are of two types.
- SOAP Web Services
- RESTful Web Services
We will discuss them in detail in upcoming tutorials.
Java Web Service APIs
Java provides different APIs that simplifies the development of web services.
- JAX-WS: This API is used for developing SOAP based web services in Java.
- JAX-RS: This API is used for developing RESTful web services in Java.
There are mainly two web service design approaches.
- Contract Last or Bottom Up Approach: In this approach the Java code is written first and then WSDL is generated.
- Contract First or Top Down Approach: In this approach the WSDL is created first and then using it the Java code is written.
Comment below if you found any information incorrect or missing in above java web services tutorial.