V Bottom up java web service
Build a full web service with Axis2
Java annotation for web services
Since JDK 5.0 it is possible to use java annotations to expose java functions and methods as a web service. In a bottom up web service, the goal is to build a web service from a existing service implementation instead of building a web service from a wsdl file.
Create a new Dynamic Web Project and add the cd-catalog.jar into the WEB-INF/lib directory. Use the CDDaoAxisImpl.java and CDServiceAxisImpl.java files.
The @WebService javax.jws annotation allow to declare our CDServiceAxisImpl.java implementation as a web service as follows :
Server generation
To generate the Axis2 java code that handle our web service declaration, right click on the annotated CDServiceAxisImpl.java file in the Project Explorer and choose Web Services > Create Web service.
Choose Install service in the top left spinner, and select :
- the target Server (Tomcat)
- the target Web service runtime (Axis2)
- the Service project (Axis2TutorialServer)
Start the server and check the generated wsdl at http://localhost:8080/Axis2TutorialServer/services/CDServiceAxisImplService?wsdl. If your service is up and running you should see something like this :
You can see that all of the methods defined in CDServiceAxisImpl.java are available and also that the mapping defined in the wsdl schema directly maps to the cd.catalog.mapping.CD object.