Creating a JAX-WS under eclipse is not a big problem when using Tomcat. According to CXF developers, deploying a JAX-WS under glassfish SHOULD not be a problem, however, when using glassfish, things does not work as expected. Not because glassfish and CXF are not compatible, but because some steps or extra steps were made wrong. This step by step tutorial should show how to create a JAX-WS with Eclipse and Glassfish.Create a Dynamic Web Project in eclipse.
- CXF 2.x Web Services
- Dynamic Web Module
- Glassfish Deployment description Files
On the configuration Panel, click on modify and select the following options (also shown in figure 2):
When finished, click ok à and then finish. A project structure as showed in figure 3 would be created.
Create a Web Service interface and an implementation class of your web Service.
Once all the classes are implemented, right click on the implementation class of the Service and go to-> new ->Others -> Web Services -> Web Service and then click next.
A web service wizard will be started. In this tutorial we will create a Bottom up java Web Service. Your implementation class will be automatically selected. If not, select the implementation class in the Service Implementation tab. On the configuration console, please select the right deployment server (Glassfish) and the right Web Service Runtime environment. (Normally an Apache Tomcat as well as Axis2 Runtime will be automatically selected; this must change as shown in figure 6). Once finished, click on next.
Click on Use Service Endpoint Interface and select your service endpoint interface (SEI) from your project. If you still don’t’ have one, the wizard could create one for you. Click next
Now select the JAX-WS annotation to be added to your Implementation class. Now, this step is really important. Only select @ WebMethod and @WebParam annotations. Selecting other ones will result that your Web Service my have some deployment difficulties or that the Web Service WSDL URL on the Glassfish Admin console (See figure 13) will not work properly. When finished, click next
Click only Generate Wrapper and Fault Beans. You really don’t need the WSDL since it is regenerated automatically when deployed. Now click finish
The Wrapper classed and annotations will be generated and the project will be deployed into Glassfish
Now the service is deployed into Glassfish. Go to Glassfish admin console (http://localhost:4848) à Web Application and click on the ConverterEAR.?
A new window will be opened where are all deployed components are showed.
On the Action Tab (Aktion in the figure) please click on show. The new web site will have two links, one for the WSDL and the other for a test Site where the Web Service would be tested…