Copyright © 2010 Skyway Software
Abstract
This tutorial details the steps required to generate and publish JAX-WS web services in a project in MyEclipse for Spring.
Table of Contents
JAX-WS (Java API for XML Web Services) is a Java programming language API for creating web services. It is part of the Java EE platform from Sun Microsystems. Like the other Java EE APIs, JAX-WS uses annotations, introduced in Java SE 5, to simplify the development and deployment of web service clients and endpoint.
MyEclipse for Spring provides a simple to use editor that generates the necessary java client and endpoint, plus configuration files to generate a JAX-WS web service. This web services tutorial is going to focus on showing how quickly a developer can enable web services after scaffolding a table. In a matter of seconds, a MyEclipse for Spring user can go from one or more tables to a full functioning Spring application with JAX-WS web services. The tutorial will then take a look at the MyEclipse Web Services explorer to test the newly generated SOAP web service.
What's generated?
JAX-WS client: [package].service.jaxws.[Service name]Client.java
JAX-WS endpoint: [package].service.jaxws.[Service name]Endpoint.java
JAX-WS Spring config: resources/jaxws/jaxws-web-context.xml
Security config (if enabled): resources/[Project name]-generated-security-context.xml
Annotations used:
@WebService
@SOAPBinding: Specifies the mapping of the Web Service onto the SOAP message protocol
@ResponseWrapper: Used to annotate methods in the Service Endpoint Interface with the response wrapper bean to be used at runtime.
@RequestWrapper: Used to annotate methods in the Service Endpoint Interface with the request wrapper bean to be used at runtime.
The prerequisites needed to complete this tutorial are:
MyEclipse for Spring 8.5 Edition
Completed Spring MVC CRUD Tutorial. This tutorial builds off the concepts described in the Spring MVC Scaffolding tutorial. Scaffolding a full functioning Spring application in a matter of minutes is detailed in that tutorial.
The following steps review how to quickly bootstrap and scaffold a project in MyEclipse for Spring to generate a ready to run Spring MVC app complete with CRUD operations. To learn more about Scaffolding, please take a look at the Spring MVC Scaffolding tutorial.
Create a MyEclipse Web Project (or Eclipse Dynamic Web Project) called CustomersApp.
Right-click on the CustomersApp project, and choose MyEclipse > Add Spring Code Generation Capabilities...Accept all defaults.
This will bootstrap the project with Spring configuration files and libraries. It will also add the MyEclipse for Spring Editors capability to the project. The editors is where the JAX-WS generation capability is accessed.
Right-click on the CustomersApp project, and choose MyEclipse > Scaffold Spring MVC CRUD application from...
Choose the Database Schema option on the Select Artifact Type(s) panel. Click the Next button.
Click the Next button to select the MyEclipse Derby connection.
Select the CUSTOMER table from the CLASSICCARS schema. Click the Next button.
Click Next through the next pane.
Enter org.customerapp as the base package. Click Next for a summary or Finish to scaffold the CRUD operations.
It's now time to automatically generate all the necessary Java/Spring code and configuration files to enable JAX-WS on the CustomerService. (In only 2 steps!!!)
In the Project Explorer, double-click the Spring DSL > com.customerapp.service > CustomerService editor
In the CustomerService editor, click the JAX-WS Web Service tab. Highlight the CustomerService parent node in the left-hand side text area. Check Publish Web Service on the right-hand side details pane. Save.
To deploy the application, right-click on the CustomersApp project and select Run As --> MyEclipse Server Application.
Once the MyEclipse Tomcat starts up, browse to the following URL: http://localhost:8080/CustomersApp/jaxws. This page provides a summary of all web services published. The page should look something like:
The web service can now be tested through the MyEclipse Web Services Explorer.
On the jaxws URL page, click the WSDL link. Copy the wsdl http address from your browser.
On the MyEclipse toolbar, find the Web Services Explorer icon, click the down arrow and Launch the SOAP Web Services Explorer
On the Web Services Explorer toolbar (right-hand side), click the WSDL page icon (left of the star icon).
Click the WSDL Main link in the navigator and paste the WSDL URL copied from step 1. Click Go.
Click the loadCustomers link in the Operations table. Click Go, and review the results in the Status pane.