views:

116

answers:

3

Hi,

I am totally new to Spring Web Services and so what concept should I start concentrating on and where should I be looking for them and in general what steps would you recommend to get to speed with Spring Webservices Module.

Note: I have an requirement to build Web Service for and consume Web Service from different application and I have never worked with Web Service in the past, I am looking at Spring WS option because both application are developed using Spring Framework, is this a good assumption to look for Spring WS or not ?

Any guidance and suggestion for discussion kind of approach would be highly appreciated.

Thanks.

A: 

What are your protocol requirements? Do you have to use SOAP, or are you free to use your own XML marshalling over HTTP (e.g. a RESTful approach)?

If you must use SOAP, then see this guide I wrote to Spring WS web services. If you're free to use your own lightweight RESTful web services, then see this example I wrote on RESTful web services.

James Earl Douglas
We have to use SOAP Protocol and I will go through your guide on Spring WS Web services.
Rachel
A: 

I wouldn't use Spring WS ONLY because of the reasoning you provide. You need to identify more functional requirments like:

  • Can you use markup (JSON, XML, etc.)
  • Should you provide content negotiation
  • Do you need to provide complex objects (i.e. SOAP as james suggests)
  • Are you providing a RESTful service

etc.

I've worked with web services a lot in the past few years and there seems to be a few major projects for creating them:

There are other offshoots like Spring WS, or even Spring MVC, but you need to evalute which will work best.

Personally I use Jersey a lot, which also provides Spring integration. Jersey also has an awesome HTTP client for consuming services, but don't confuse creating a web service as being akin to consuming a web service. They are separate workflows and you could use separate third-party projects for both (e.g. Apache HTTP Client for consuming, and Jersey for producing).

Spring WS might work best for you, but my advice would be don't use it just because the other applications use it...use whatever works best and fulfills your requirements.

Droo
I am not using Rest Protocol rather we are required to use SOAP Protocol and I did not got your point on complex objects generation, can you elaborate more on that ?
Rachel
To clarify, REST isn't a protocol. Take a look at the wiki for SOAP: http://en.wikipedia.org/wiki/SOAP. "SOAP, originally defined as Simple Object Access Protocol, is a protocol specification for exchanging structured information..." The struture is an object (hence the O in SOAP) which is un/marshalled to and from XML so the consumer is only ever working with an object and not a raw message or markup. SOAP works well for very complex objects because creating a malleable, lengthy markup structure is very cumbersome.
Droo
Can you explain in details about each functional requirement which you mentioned ? I am just trying to get some better understanding of how this thing is actually going to work.
Rachel
A: 

(...) I am looking at Spring WS option because both application are developed using Spring Framework, is this a good assumption to look for Spring WS or not?

It's not a wrong assumption (bad integration between Spring WS and Spring would be a total irony) but you should not exclude other stacks on the fact your applications are using Spring. JAX-WS stacks (like Apache CFX or JAX-WS RI) provide Spring integration as well.

Personally, I like JAX-WS (that I use for contract-first web services) and, while it's hard to be more specific without more details about your requirements, I simply don't think that Spring WS offers any advantages over JAX-WS and I would probably go for Apache CXF in your case.

Maybe have a look at what others are saying in this previous SO question (please read all answers, the accepted one is not really good in my opinion).

Pascal Thivent
Hmm...if am considering Apache Stack than what are the deciding factors on going for `Axis2 v/s CFX`, I have used neither of them but there appears lots of buzz around Axis2 as well, how does this two stack up against each other ?
Rachel
@Rachel You'll never see me recommending Axis2. Have a look at this [previous answer](http://stackoverflow.com/questions/3588616/java-webservice-client-best-way/3590252#3590252). The only reason Axis2 is still there is because Eclipse used it during ages. But this madness is over with Eclipse 3.6 and you can now use CXF as runtime.
Pascal Thivent
@Pascal: As a matter of fact our team was thinking of using Axis2 as we have heard about it not that we have any technical basis for it as we all are new to Web Services Development and this is first time we are going for it, so CXF would be an better option in your opinion, what are your thoughts on `Artix` ?
Rachel
@Rachel If you like to suffer, if you're looking for pain, Axis2 is for you :) If you like elegance, ease of use, CXF is a good choice (and it has good documentation, good tutorials, etc) and I wouldn't look further. Can't say anything about Artix.
Pascal Thivent
@Pascal: I understand your point but I have to justify why axis is not a good option to my team as they are heading towards using axis and so I would really appreciate if you can give some pointers which I can use for justification so that we do not end up using `Axis2` and not `CFX`, also as we have not used Web Service in the past we are not aware of what issues we might face and so it would really nice if you can give some headsup on issues one may encounter using `Axis2` and its benefits `CFX` would give if we go on for an comparison.
Rachel
@Rachel Well, I mentioned this [previous answer](http://stackoverflow.com/questions/3588616/java-webservice-client-best-way/3590252#3590252) where is posted *some reasons to not use Axis2 and some links*. Have a look. And Google a bit for more feedback, especially about the Spring integration (hint, Axis2 won't be the winner).
Pascal Thivent
@Pascal - Thank you for your thoughts on this, I will prepare proper documentation to support our reasoning of not using Axis2 and going for `CFX`, again thanks for your inputs.
Rachel