Web Services with Apache Axis2

Since my new project would require me to use web services, I decided to get my hands at it.

Bottom-Up Approach To Writing Web Services

The logical place to start would be take your plain old Java classes (POJOs, I love them) and expose their methods to to the web. Since you already have the implementation, this is called a bottom-up approach. And with Eclipse Ganymede and Apache Axis2 1.4.1, it was all a breeze. Just create a dynamic web project, create your POJO(s), create Web Service, choose bottom-up. The Axis2 plug-inĀ  then creates a web service complete with WSDL (web service definition language) file and all. Here are the details.

With some groping and googling, I was able to successfully connect my test Adobe Flex application to my web service with no problems.

Top-Down Approach To Writing Web Services

The next step was to do it the other way around, given a WSDL file which describes your web service in great detail, and implement your service. Since you start with just the web service description, it’s called a top-down approach. It was also a breeze. Create a dynamic web project, create a web service, choose top-down, give the location of the WSDL file (I used the WSDL generated earlier), and generate all the necessary classes along with TODO tags where you’re supposed to add your code. Put it in your implementation, compile, deploy, and you’re good to go. Here are the details.

With just a small adjustment in the WSDL URI, I was again able to successfully connect my test Adobe Flex application to my web service with no problems.

All this with no need to mess around with HTTP (it’s just the transport), SOAP (it’s just the protocol), or WSDL (it is generated). Java tooling sure makes web services easy.