MyEclipse Logo

MyEclipse for Spring 8.6: JAX-WS Annotators

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

Abstract

This tutorial provides an overview of using the JAX-WS Annotators in MyEclipse for Spring.


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 8.6 contains two new set 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.

Code Assistants

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).

    Open Spring Service

    Figure 2. Open Spring Service


  2. Switch to the JAX-WS annotator in Eclipse.

    Switch to JAX-WS Annotator

    Figure 3. Switch to JAX-WS Annotator


    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 Annotator click on the Enable JAX-WS button.

    Enable JAX-WS

    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.

    Select endpoint location

    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.

    Select context file for adding JAX-WS config

    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).

    Open Spring Service

    Figure 7. Open Spring Service


  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 code or the annotator's 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.

    Interface-level 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 annotator's 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.

    Method-level configuration

    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.

    Switch to Spring Annotator

    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

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:

Developer Resources