JBoss.orgCommunity Documentation

Chapter 2. Creating a Simple Web Service

2.1. Generation

This chapter describes how to create a simple web service.

A simple web service can be created by using the Simple Web Service wizard as described in Generate a simple web service

Procedure 2.1. Generate a simple web service

  1. Access the New - Select a wizard dialog

    1. Right click on the project name in the Project Explorer view.

    2. Select NewOther.

    3. Expand the Web Services folder and click on the Simple Web Service option.

    Result:

    The New - Select a wizard dialog displays with the selected wizard type highlighted.

    Figure 2.1. The New - Other (Wizard selection) dialog


  2. Access the Simple Web Service dialog

    Click the Next button to proceed.

    Result:

    The Simple Web Service - Project and Web Service Details dialog displays.

    Figure 2.2. Simple Web Service - Project and Web Service Details


  3. Define the service attributes

    Define the project, web service, package and class names according to the options displayed in Table 2.1, “Project and Web Service Details”

    Table 2.1. Project and Web Service Details

    Dialog groupFieldMandatoryInstructionDescription
    Technology yesSelect the technology the Web Service will be based on.A simple web service can be based on either the Web Service Definition Language (WSDL) or RESTful (REST) API. Click the radio button beside the technology your web service should use.
    Dynamic web project yesSelect the project name.The project name will default to the highlighted project in the Project Explorer. A different project can be selected from the drop-down list.
    Service detailsService nameyesEnter the name for the web service.The web service name will be the URL for the service as mapped in the deployment descriptor (web.xml).
     Update web.xmlnoCheckbox is checked by default, but is not mandatory.Leaving this checked will add your new service to the web.xml in your project.
    Add RESTEasy Jars from root runtime directorynoCheck this box to add RESTEasy JARs to the project.This option allows you to add RESTEasy JARs to the project if they appear in the root runtime directory but are not installed in the runtime. While this is not required, it will assist when working with JBoss Application Server 5 and JBoss Enterprse Application Platform 5 web service projects.
    Service implementationPackageyesEnter the package for the web service servlet.The default package is org.jboss.samples.websevices. Select your own package using the ... button.
     ClassyesEnter the name of the web service servlet.The default class name will correspond to the default web service name resulting in an equivalent URL to servlet name mapping in the deployment descriptor (web.xml).
     Application classonly when the JAX-RS technology option is selectedEnter the name of the JAX-RS application class to use.The default application class is MyRESTApplication.Select your own application class using the ... button.

  4. Generate the web service

    Click the Finish button to complete the web service setup.

    Result:

    The web service classes will be generated and the web.xml file updated with the deployment details if the Update web.xml option was selected.

    Figure 2.3. Created Simple Web Service