facebook

Using JAX-WS Annotators with Spring

This tutorial walks you through using the JAX-WS Annotator to produce a JAX-WS web service from a Spring service.  In this tutorial, you will learn how to:

  • Enable JAX-WS for a Spring service
  • Deploy the application and test the service
All tasks related to Spring scaffolding require a MyEclipse Spring or Bling subscription.


1. Enable JAX-WS for a Spring Service

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

  1. Create a scaffolded CustomersApp project.
  2. In the CustomerApp web project, open the Service implementation class (org.customerapp.service.CustomerServiceImpl.java).

    Opening the Spring service
  3. Switch to the JAX-WS Annotations view. If the view isn’t visible, open it by selecting Window>Show View.
  4. Click Enable JAX-WS.

    Enabling JAX-WS
  5. Select the org.customerapp.service package as the location/package where the endpoint should be generated.

    Selecting endpoint location
  6. Select CustomersApp-service-context.xml from the list of all Spring context files in the project. Your selection is the individual context file that should be updated with the required JAX-WS configuration.

    Selecting the context file for adding JAX-WS config
  7. Save the changes, and then open the service endpoint interface (org.customerapp.service.CustomerServiceImplEndpoint.java).

    Opening service endpoint

Although no additional configuration is required for this tutorial, the JAX-WS annotator lets you further configure the service endpoint with relevant JAX-WS annotations. If you double-click the interface name (CustomerServiceImplEndPoint) in the code or select it in the outline view, the configuration panel displays 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 configurations

The JAX-WS annotator also lets you further configure the class/interface methods with relevant JAX-WS annotations. If you double-click the deleteCustomer() method in the code or select it in the outline view, the configuration panel displays 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 configurations


2. Deploy the Application and Test the JAX-WS Web Service

  1. Right-click CustomersApp, and select Run As>MyEclipse Server Application.
  2. With the application deployed, click the Open Web Service Explorer link on the JAX-WS annotator. This opens the WSDL in the Web Service explorer, which can be used for testing the web service.

    Opening the Web Service explorer

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