< Previous | Next >

Lesson 1: Creating a server and web project

In this lesson you will learn how to create a server and web project for use with web services.

Create a JAX-WS enabled server

Before creating the web service you need to ensure you have a WebSphere Application Server v8.0 server defined and started. By default a server is created for you when you install WebSphere Application Server. This server can be seen in the Servers view. However if you want to create a new server do the following:
  1. From the File menu, select New > Other > Server > Server > Next.
  2. Select WebSphere Application Server v8.0 as the server type. Click Next.
  3. If this runtime has not been created in your workspace, you will be prompted to select the installation directory for the server. Click Next.
  4. Accept the default server port and name. For this tutorial the default server name used will be server1. Click Finish.
  5. Wait for the server to start. once it has started the Console view will display Server server1 open for e-business. If the server does not start automatically select it in the Servers view and click the start icon: server start icon.

Create a web project for the web service

The web services wizards can create a web project for the web service and enable the facets for you, however in this tutorial you will create the project manually.
  1. In the Java™ EE perspective, right-click your enterprise application project and select New > Web Project to open the web project wizard.
  2. In the Name field, type a name for your new web project. For this tutorial, use jwsAddressBook.
  3. In the Project Templates section, select the type of web template you want to use: For this tutorial, select Simple.
    Option Description
    Dojo Toolkit Configures the project to have Dojo capabilities. The Dojo resources can be in the project itself, a separate project, or a remote location accessible via HTTP.
    JavaServer Faces Enables the project to be deployed with JSF capabilities. Configuration is provided for either JSP or Facelets.
    REST Services A project configured for REST Services based on JAX-RS
    Simple This creates a basic web project.
  4. In the Programming Model section, select the programming model you want to use: For this tutorial, select Java EE.
    • Client-side only (HTML, JavaScript,...)
    • Java EE
    • OSGi
  5. Click Next to configure your new web project.
  6. On the deployment page, from the list of available configuration options, click Deployment to open the Deployment configuration page.
    • In the Target runtime field, select the v7 or v8 WebSphere Application Server that you installed earlier in the tutorial.
    • In the Web module version field, accept the default (which is automatically selected based on which WebSphere Application Server you selected).
    • In the EAR Membership field, select Add project to an EAR, and ensure that jwsAddressBookEAR is the EAR project name.
    • Under the Deployment section, select Change Features. On the Project Facets page, select JAX-RS (REST Web Services), version 1.1, and click OK.
  7. From the list of available configuration options, click Java to open the Java configuration page.
    • In the Source folders on build path field, accept the default src directory, or click Add Folder, Edit... or Remove to specify a folder for your source files.
    • In the Default output folder: field, specify a folder for your output files or accept the default value (WebContent\WEB-INF\classes).
      Important: If you choose a folder other than WebContent\WEB-INF\classes for your default output folder, the problems view will report a warning:
      Single root source folder
      Single root warning
      The default for single rootedness problems is set to warning. To change this setting, select Window > Preferences > Validation > Project Structure Validation. Click the ... settings field, and select
      1. Error
      2. Warning
      3. Ignore
      Validator preferences
  8. From the list of available configuration options, click Web Module.. On the Web Module configuration page,
    • In the Context root field, type the name of your web project root, or accept the default (which is the name of your web project).
    • In the Content directory field, type the name of your content directory, or accept the default (WebContent).
    • Select Generate web.xml deployment descriptor if you want to create a deployment descriptor. You can also add a deployment descriptor to your web module later.You need to use a web.xml to configure security constraints and other behavior.
  9. Click Finish.

Create a web project for the web service client

The web services wizards can create a web project for the client and enable the facets for you, however in this tutorial you will create the project manually.
  1. In the Java EE perspective, right-click your enterprise application project and select New > Web Project to open the web project wizard.
  2. In the Name field, type a name for your new web project. For this tutorial, use jwsAddressBookClient.
  3. In the Project Templates section, select the type of web template you want to use: For this tutorial, select Simple.
    Option Description
    Dojo Toolkit Configures the project to have Dojo capabilities. The Dojo resources can be in the project itself, a separate project, or a remote location accessible via HTTP.
    JavaServer Faces Enables the project to be deployed with JSF capabilities. Configuration is provided for either JSP or Facelets.
    REST Services A project configured for REST Services based on JAX-RS
    Simple This creates a basic web project.
  4. In the Programming Model section, select the programming model you want to use: For this tutorial, select Java EE.
    • Client-side only (HTML, JavaScript,...)
    • Java EE
    • OSGi
  5. Click Next to configure your new web project.
  6. On the deployment page, from the list of available configuration options, click Deployment to open the Deployment configuration page.
    • In the Target runtime field, select the v7 or v8 WebSphere Application Server that you installed earlier in the tutorial.
    • In the Web module version field, accept the default (which is automatically selected based on which WebSphere Application Server you selected).
    • In the EAR Membership field, select Add project to an EAR, and ensure that jwsAddressBookEAR is the EAR project name.
    • Under the Deployment section, select Change Features. On the Project Facets page, select JAX-RS (REST Web Services), version 1.1, and click OK.
  7. From the list of available configuration options, click Java to open the Java configuration page.
    • In the Source folders on build path field, accept the default src directory, or click Add Folder, Edit... or Remove to specify a folder for your source files.
    • In the Default output folder: field, specify a folder for your output files or accept the default value (WebContent\WEB-INF\classes).
      Important: If you choose a folder other than WebContent\WEB-INF\classes for your default output folder, the problems view will report a warning:
      Single root source folder
      Single root warning
      The default for single rootedness problems is set to warning. To change this setting, select Window > Preferences > Validation > Project Structure Validation. Click the ... settings field, and select
      1. Error
      2. Warning
      3. Ignore
      Validator preferences
  8. From the list of available configuration options, click Web Module.. On the Web Module configuration page,
    • In the Context root field, type the name of your web project root, or accept the default (which is the name of your web project).
    • In the Content directory field, type the name of your content directory, or accept the default (WebContent).
    • Select Generate web.xml deployment descriptor if you want to create a deployment descriptor. You can also add a deployment descriptor to your web module later.You need to use a web.xml to configure security constraints and other behavior.
  9. Click Finish.

Import the address book WSDL file

Import the required WSDL file. The import wizard will import a simple project containing the WSDL file.

Import the Address Book tutorial resources

Lesson Checkpoint

Now you are ready to begin Lesson 2: Creating the web service.

< Previous | Next >

Feedback