I have recently met a client who asking me to rebuild their legacy product using Java web service.
They want it modular and easy to use. The first thing crossed my mind is using restful approach.
But there is only thing that bothers me, Java restful approach is using XML!, I would prefer a simpler way to communicate, easy to understand and parsed data, so Json it is. I started google-ing a little and came across this excellent blog.
I read the blog but it seem there some minor problem which they (he and the blog commenter) already solved.
So I am not here to revise on anything just to sum it up so it will be easier for you to build a Json web service with Java and Axis2.
The steps are not so different with my reference blog, but I have minor modification on the steps.
1. Download the Axis2 war that includes jetisson patch and DynamicRespondHandler Axis2 Module here
Note that the Axis2 above is pre-configure,but still I would like to show what the changes are:
- Added module reference to the
- Added Json Message formatters
<messageFormatter contentType="application/json" class="org.apache.axis2.json.JSONMessageFormatter"/> <messageFormatter contentType="application/json/badgerfish" class="org.apache.axis2.json.JSONBadgerfishMessageFormatter"/>
- Added Json Message builders
<messageBuilder contentType="application/json" class="org.apache.axis2.json.JSONOMBuilder"/> <messageBuilder contentType="application/json/badgerfish" class="org.apache.axis2.json.JSONBadgerfishOMBuilder"/>
2. Download you favorite Java application server, in this case I am using Apache Tomcat 7.0.
3. Deploy Axis2 war to your application server, in my case I just copy the Axis2 war to Tomcat`s
your browser should shows this:
So that is the start, I hopefully can post more about this in the future. Cheers.