Thursday, July 09, 2009

using jaxws 2.1 for exposing web services

jaxWS 2.1 simplifies web service development for java based applications. It is very easy to expose your pojo service classes as web services just using web service annotations.

Just put @WebService annotation on your service class, that's all . You can also restrict number of methods to be exposed using @WebMethod annotation on methods of exposed service class.

For the GlassFish V2 you dont have to add anything to web.xml file for the web services. All of required definitions will be added by GlassFish during the deployment. On the other hand , for the tomcat, you have to add listener definitions into web.xml file to run web services.

During the deployement all classes containing web service annotations are scanned by AS and required web service classes are generated using wsgen tool. For this process you need JDK that contains wsgen and apt tools. If you specified jre you will get the following error message during deployment. runtime modeler error: Wrapper class {0} is not found. Have you run APT to generate them?