MyEclipse Logo

MyEclipse for Spring 10.0: JAX-WS Annotators

How to use the JAX-WS Annotators for publishing a Spring service as a SOAP web service

Niel Eyde

Skyway Software, Inc.

Table of Contents

1. Introduction to Annotators
2. Goal
3. Prerequisites
4. Enable JAX-WS for Spring Service
5. Deploy and Run JAX-WS Web Service
6. Conclusion
7. Additional Developer Resources

1. Introduction to Annotators

Annotators are part of the code assistants that are available in MyEclipse for Spring, and annotators help developers with annotation-based development. While most JAVA developers understand how to technically use JAVA annotations, it's not always clear which annotations are available for a specific technology and when a particular annotation should be use. For example, the Spring framework has excellent support for annotation-based programming, however there are a lot of supported annotations. Some annotations are applicable to all Spring stereotypes, and other annotations are only applicable to specific stereotypes. Annotators support annotation-based development by helping a developer understand what annotations are available and in what context the annotation should be used.

MyEclipse for Spring 10.0 contains three sets of annotators. The Spring Annotator helps Spring developers annotate Spring controllers, services, components and repositories. The JAX-WS Annotator is for configuring JAX-WS web services, and the JPA Annotator is for configuring JPA entities.

Figure 1. Code Assistants


2. Goal

This tutorial is going to walk you through using the JAX-WS Annotator to produce a JAX-WS web service from a Spring Service. As a starting point, this tutorial will use a previously scaffolded application (see scaffolding tutorial). The scaffolded Spring Service will be JAX-WS enabled and deployed in minutes.

You may also be interested in the Spring Annotator for configuring Spring components web services (see Additional Developer Resources)..

3. Prerequisites

The prerequisites needed to complete this tutorial are

4. Enable JAX-WS for Spring Service

The JAX-WS annotator will configure the web project for JAX-WS support and configure the Spring Service to be JAX-WS endpoint.

  1. In the CustomerApp web project, open the Service implementation class (org.customerapp.service.CustomerServiceImpl.java).

    Figure 2. Open Spring Service


  2. Switch to the JAX-WS Annotations editor in Eclipse.

    Figure 3. Switch to JAX-WS Annotations editor


    The JAX-WS Annotator is implemented as an Eclipse View. If the View isn't visible, you can add it using the Window-->Show View option.

  3. From the JAX-WS Annotation editor click on the Enable JAX-WS button.

    Figure 4. Enable JAX-WS


  4. Next you are prompted for the location/package where the endpoint should be generated. Select the org.customerapp.service package.

    Figure 5. Select endpoint location


  5. Next you are presented with a list of all Spring context files in the project, and you must specify the individual context file that should be updated with the required JAX-WS configuration. Select CustomersApp-generated-service-context.xml.

    Figure 6. Select context file for adding JAX-WS config


  6. The service endpoint interface should have been generated to the org.customerapp.service package. Open the service endpoint interface (org.customerapp.service.CustomerServiceImplEndpoint.java).

    Figure 7. Open service endpoint


  7. Although additional configuration is not required for this tutorial, the JAX-WS annotator will let you further configure the service endpoint with relevant JAX-WS annotations. If you highlight the interface name (CustomerServiceImplEndPoint) in the code or the outline view, the configuration panel will show you a list of available class-level annotations. As you configure the class/interface using the annotator, the service endpoint is immediately updated to reflect the configuration.

    Figure 8. Interface-level configuration


  8. The JAX-WS annotator will also let you further configure the class/interface methods with relevant JAX-WS annotations. If you highlight the deleteCustomer() method in code or the outline view, the configuration panel will show you a list of available method-level annotations. There are many JAX-WS annotations and configuration options, and they are grouped into categories that can be accessed using tabs.

    Figure 9. Method-level configuration


    For this tutorial we'll use the default JAX-WS configuration. So additional configuration is not required.

That's it. In less than a minute your Spring service is configured as a service endpoint using JAX-WS.

5. Deploy and Run JAX-WS Web Service

Finally you can redeploy the web project and test the service.

  1. To deploy the application, right-click on the CustomersApp project and select Run As --> MyEclipse Server Application.

  2. Once the application is deployed, click on the Open Web Service Explorer link on the JAX-WS annotator. This will open the WSDL in the Web Service Explorer, which can be used for testing the web service.

    Figure 10. Switch to Spring Annotator


    In case you want to test the service in another testing tool, the WSDL URL is: http://localhost:8080/CustomersApp/jaxws/CustomerServiceImplEndPoint?wsdl

    The Open Web Service Explorer link assumes that your server is running on port 8080. If you are running on a different port, you will need manually modify the URL with the correct port.

6. Conclusion

This tutorial walked you through the use of the JAX-WS Annotator for creating JAX-WS web services from Spring services.

What was your experience with this tutorial? Share your experience with us by completing a very brief survey.

7. Additional Developer Resources

Thank you for you interest in MyEclipse for Spring. If you are interested in learning more, the following developer resources are available: