JBoss.orgCommunity Documentation

Chapter 6. Sample Web Service wizards

6.1. Sample Web Service
6.1.1. Generation
6.1.2. Deployment

JBoss Tools includes wizards for the creation of sample web services. These include:

This wizard is used within a Dynamic Web project. A dynamic web project can be created by following the steps in Creating a dynamic web project.

Procedure 6.1. Creating a dynamic web project

  1. Access the New Project Dialog

    Select FileNewProject

    Result:

    The New Project screen displays.

  2. Define the Project Type

    1. Click the Dynamic Web Project label by expanding the Web folder.

    2. Click the Next button to proceed.

    Result:

    The New Dynamic Web Project screen displays.

    Figure 6.1. Dynamic Web Project Attributes


  3. Define the Project Attributes

    Define the Dynamic Web Project attributes according to the options displayed in Table 6.1, “New Dynamic Web Project”

    Table 6.1. New Dynamic Web Project

    FieldMandatoryInstructionDescription
    Project nameyesEnter the project name.The project name can be any name defined by the user.
    Project locationyesClick the Use default location checkbox to define the project location as the Eclipse workspace or define a custom path in the Location field.The default location corresponds to the Eclipse workspace.
    Target runtimenoSelect a pre-configured runtime from the available options or configure a new runtime environment.

    The target runtime defines the server to which the application will be deployed.

    Dynamic web module versionyesSelect the required web module version.

    This option adds support for the Java Servlet API with module versions corresponding to J2EE levels as listed in Table 6.2, “New Dynamic Project - Dynamic web module version”.

    ConfigurationyesSelect the project configuration from the available options.

    The project can be based on either a custom or a set of pre-defined configurations as described in Table 6.3, “New Dynamic Project - Configuration”.

    EAR membershipnoAdd the project to an existing EAR project.

    The project can be added to an existing EAR project by selecting the checkbox. Once checked, a new EAR project can be defined by clicking the New Project button.

    Working setsnoAdd the project to an existing working set.

    A working set provides the ability to group projects or project attributes in a customized way to improve access. A new working set can be defined once the Select button has been clicked.




  4. Access the Java sub-dialog

    Click Next to proceed.

    Result:

    The New Dynamic Web Project - Java dialog displays.

  5. Define the source and output folders

    Define the Dynamic Web Project source and output folders by adding or editing folders as required.

  6. Access the Web Module sub-dialog

    Click Next to proceed.

    Result:

    The New Dynamic Web Project - Web Module dialog displays.

    Figure 6.2. New Dynamic Web Project - Web Module


  7. Enter the web module settings

    Define the settings as listed in Table 6.4, “New Dynamic Web Project - Web Module” including the root folder for path names in the web project context and the name of the web content directory.


  8. Open the Java EE perspective.

These sections describe how to generate and deploy a sample web service.

A sample web service can be created by using the Create a Sample Web Service wizard as described in Generate a sample web service

Procedure 6.2. Generate a sample 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. Click the Create a Sample Web Service label by expanding the Web Services folder.

    Result:

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

  2. Access the Generate a Sample Web Service dialog

    Click the Next button to proceed.

    Result:

    The Generate a Sample Web Service - Project and Web Service Name dialog displays.

    Figure 6.3. Generate a Sample Web Service - Project and Web Service Name


  3. Define the service attributes

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


  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.

  5. Browse the HelloWorld.java class

    Double click the HelloWorld.java class and note the annotated class name and method. These annotations identify the web service entities to the server.

    Figure 6.4. web.xml


  6. Browse the web.xml deployment decriptor

    Double click the web.xml file and note the servlet mapping as defined in Figure 6.3, “Generate a Sample Web Service - Project and Web Service Name”. Note also that:

    • the main servlet for the application is org.jboss.samples.webservices.HelloWorld which is given the custom name HelloWorld; and

    • the main servlet is mapped to the particular url /HelloWorld [1].

    Figure 6.5. web.xml


    Upon start up, the server will write a WSDL file to the server-profile/data/wsdl/ directory and the WSDL can be accessed with http://localhost:8080/ProjectName/[1]?WSDL or, http://localhost:8080/WebServiceSample/HelloWorld?WSDL.

Once created, the sample web service can be deployed to the target runtime as described in Export the project as a Web Archive (WAR).