Copyright © 2011 Skyway Software
Table of Contents
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.
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)..
The prerequisites needed to complete this tutorial are
Download MyEclipse for Spring 10.0
CustomersApp Web Project - this scaffolded Spring MVC application was created using the Spring Scaffolding tutorial that is available in the Eclipse help system and online (under MyEclipse for Spring Education Materials)
The JAX-WS annotator will configure the web project for JAX-WS support and configure the Spring Service to be JAX-WS endpoint.
In the CustomerApp web project, open the Service implementation class (org.customerapp.service.CustomerServiceImpl.java).
Switch to the JAX-WS Annotations editor in Eclipse.
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.
From the JAX-WS Annotation editor click on the Enable JAX-WS button.
Next you are prompted for the location/package where the endpoint should be generated. Select the org.customerapp.service package.
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.
The service endpoint interface should have been generated to the org.customerapp.service package. Open the service endpoint interface (org.customerapp.service.CustomerServiceImplEndpoint.java).
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.
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.
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.
Finally you can redeploy the web project and test the service.
To deploy the application, right-click on the CustomersApp project and select Run As --> MyEclipse Server Application.
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.
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.
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.
Thank you for you interest in MyEclipse for Spring. If you are interested in learning more, the following developer resources are available:
Reference - Eclipse Help (MyEclipse for Spring 10.0 --> MyEclipse for Spring Reference) or Education Materials (online)
Tutorials - Eclipse Help (MyEclipse for Spring 10.0 --> Tutorials) or Education Materials (online)
Screencasts - MyEclipse for Spring YouTube Channel (online)
Support Forums - MyEclipse for Spring Forums (online)
Blog - MyEclipse for Spring Posts (online)