Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I need to learn Web Services in Java. What are the different types in it? [closed]

Recently, I decided to start learning about java web services and when I started to search a tutorial for java web-services in google, I found out that there are many types of webservices XML based, SOAP based, also RESTful webservices.

Also, I found that there is a JAX-WS specification for xml based web-services, and JAX-RS specification for creating RESTful webservices.

Q1) I got confused, it would be great if anybody can help me understanding the difference between these different type of webservices, so that I can decide which one to learn first.

Q2) Also, I want to learn in-depth about creating different types of web-services in java. Is there any tutorial or resources which can give an insight to each kind of webservice and a comparison between them.

Q3) based on what scenarios and conditions should I decide that I want to create an XML based web-service rather than a SOAP service or I should go with RESTful service.

like image 357
Rajesh Pantula Avatar asked May 11 '12 19:05

Rajesh Pantula


People also ask

How many types of web services are there in Java?

Generally, there are two types of web services as follows: Soap Web Services. RESTful Web Services.

How many types of web services are there?

There are two types of web services: RESTful Web Servies. SOAP Web Services.

How can I learn web services in Java?

The java web service application can be accessed by other programming languages such as . Net and PHP. Java web service application perform communication through WSDL (Web Services Description Language). There are two ways to write java web service application code: SOAP and RESTful.


2 Answers

  1. SOAP Web Services are standard-based and supported by almost every software platform: They rely heavily in XML and have support for transactions, security, asynchronous messages and many other issues. It’s a pretty big and complicated standard, but covers almost every messaging situation. On the other side, RESTful services relies of HTTP protocol and verbs (GET, POST, PUT, DELETE) to interchange messages in any format, preferable JSON and XML. It’s a pretty simple and elegant architectural approach.
  2. As in every topic in the Java World, there are several libraries to build/consume Web Services. In the SOAP Side you have the JAX-WS standard and Apache Axis, and in REST you can use Restlets or Spring REST Facilities among other libraries.

With question 3, this article states that RESTful Services are appropiate in this scenarios:

  • If you have limited bandwidth
  • If your operations are stateless: No information is preserved from one invocation to the next one, and each request is treated independently.
  • If your clients require caching.

While SOAP is the way to go when:

  • If you require asynchronous processing
  • If you need formal contract/Interfaces
  • In your service operations are stateful: For example, you store information/data on a request and use that stored data on the next one.
like image 71
Carlos Gavidia-Calderon Avatar answered Sep 21 '22 14:09

Carlos Gavidia-Calderon


Q1) Here are couple things to read or google more :

Main differences between SOAP and RESTful web services in java http://www.ajaxonomy.com/2008/xml/web-services-part-1-soap-vs-rest

It's up to you what do you want to learn first. I'd recommend you take a look at the CXF framework. You can build both rest/soap services.

Q2) Here are couple of good tutorials for soap (I had them bookmarked) :

http://united-coders.com/phillip-steffensen/developing-a-simple-soap-webservice-using-spring-301-and-apache-cxf-226

http://www.benmccann.com/blog/web-services-tutorial-with-apache-cxf/

http://www.mastertheboss.com/web-interfaces/337-apache-cxf-interceptors.html

Best way to learn is not just reading tutorials. But you would first go trough tutorials to get a basic idea so you can see that you're able to produce something(or not) and that would get you motivated.

SO is great way to learn particular technology (or more), people ask lot of wierd questions, and there are ever weirder answers. But overall you'll learn about ways to solve issues on other way. Maybe you didn't know of that way, maybe you couldn't thought of it by yourself.

Subscribe to couple of tags that are interesting to you and be persistent, ask good questions and try to give good answers and I guarantee you that you'll learn this as time passes (if you're persistent that is).

Q3) You will have to answer this one yourself. First by deciding what you're going to build, after all you will need to think of some mini project or something and take it from there.

If you decide to use CXF as your framework for building either REST/SOAP services I'd recommend you look up this book Apache CXF Web Service Development. It's fantastic, not hard to read and not too big either (win win).

like image 35
ant Avatar answered Sep 19 '22 14:09

ant