MyEclipse Logo

MyEclipse for Spring 8.5: Generate and Publish Web Services

Generate JAX-WS web services in seconds

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

1. Introduction
2. Prerequisites
3. Bootstrap and Scaffold a Project
4. Enable Web Service Generation
5. Deploy the App
6. Web Services Explorer

1. Introduction

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.

2. Prerequisites

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.

3. Bootstrap and Scaffold a Project

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.

  1. Create a MyEclipse Web Project (or Eclipse Dynamic Web Project) called CustomersApp.

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

  3. Right-click on the CustomersApp project, and choose MyEclipse > Scaffold Spring MVC CRUD application from...

  4. Choose the Database Schema option on the Select Artifact Type(s) panel. Click the Next button.

  5. Click the Next button to select the MyEclipse Derby connection.

  6. Select the CUSTOMER table from the CLASSICCARS schema. Click the Next button.

  7. Click Next through the next pane.

  8. Enter org.customerapp as the base package. Click Next for a summary or Finish to scaffold the CRUD operations.

4. Enable Web Service Generation

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

  1. In the Project Explorer, double-click the Spring DSL > com.customerapp.service > CustomerService editor

    Spring DSL Service Editor

    Figure 1. Spring DSL Service Editor


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

    Publish Web Service

    Figure 2. Publish Web Service


5. Deploy the App

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

  2. 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:

    CustomerApps - jaxws URL

    Figure 3. CustomerApps - jaxws URL


6. Web Services Explorer

The web service can now be tested through the MyEclipse Web Services Explorer.

  1. On the jaxws URL page, click the WSDL link. Copy the wsdl http address from your browser.

  2. On the MyEclipse toolbar, find the Web Services Explorer icon, click the down arrow and Launch the SOAP Web Services Explorer

    Launch the SOAP Web Services Explorer

    Figure 4. Launch the SOAP Web Services Explorer


  3. On the Web Services Explorer toolbar (right-hand side), click the WSDL page icon (left of the star icon).

  4. Click the WSDL Main link in the navigator and paste the WSDL URL copied from step 1. Click Go.

  5. Click the loadCustomers link in the Operations table. Click Go, and review the results in the Status pane.