Java Web Services
This entry was posted on May 07 2009
So I just spent a good chunk of time looking around at web service libraries for Java. My criteria were not long:
- JSON support, really SOAP wasn’t that much of a requirement, but all of the mature libraries support it.
- Simple to setup and develop with
- Easy to maintain services
First, I tried my old standby Apache Axis.
- I found it fairly difficult to find documentation on running Axis services in a web container. Whatever, I got through that, it’s actually pretty easy once you find the right page.
- Running JSON services is not that easy. Axis default to adding namespaces to everything, but the out of the two JSON types:
- Badgerfish - the formatting is just wierd, and not that great for typical Javascript development
- Mapped - this was normal, but then really didn’t work well with namespaces
- All of this really lead to having to hand edit the WSDL files to get a good result with JSON services. This really isn’t that great for maintaining.
- Also, it just seemed like too many jars were brought in by the Axis pom file
So I moved on to trying out JAX-WS from Sun.
- Setting up a SOAP based web service using these libraries was a little bit tough in terms of finding good documentation, but turned out to not be that bad.
- Building JSON with the JAX-WS was a disaster. Neither of the libraries I could find really worked at all.
- JAX-WS Commons JSON was the first library I tried. The basic setup was pretty easy, but it just doesn’t work well with object return types. So a no go.
- http://code.google.com/p/jsonwebservice/ was the second library I tried out - again, it just didn’t do it.
At this point, I was still developing on Axis and kind of resolving myself to having to maintain a WSDL file but I stumbled across Jersey. Jersey is Sun’s REST library, and while I wasn’t necessarily looking for a resty library:
- Jersey works! This page has a good outline of what you need to do from maven to web container.
- It’s so easy, JSON, SOAP, both super easy. Not much config, just point your web.xml at the packages with your services.
- The test framework is very well thought out too, and works well with JUnit.
And that’s it. Use Jersey, and hope that Oracle likes it (so they don’t make it disapear).
