< Previous | Next >

Lesson 1.3: Create the web service

Before you begin

Before you begin, you must complete Lesson 1.2: Import and validate the WSDL file.

About this task

Before you attempt to create a web service it is strongly suggested that you start the WebSphere® Application Server on which the web service will run. Although you can start the server in the web service wizards, since it may take several minutes to start depending on the speed of your machine, starting the server before you begin will both increase the speed with which you complete the wizard and reduce the chance that the wizard will generate an error because the server is taking too long to start.

Procedure

To start the server, select the server in the Servers view and select Start:
WebSphere Application Server in the Servers view

What to do next

If the Servers view is not open in your workspace, open it from the Window menu by selecting Show View > Servers.

Create a web service from a WSDL file

The web service wizard assists you in creating a new web service, configuring it for deployment, and deploying the web service to a server. Once your web service is deployed, the wizard assists you in generating the client proxy and sample application to test the web service.

Procedure

  1. In the Project Explorer, select the ConvertTemperature.wsdl document in your EJB project.
  2. Click File > New > Other. Select Web Services in order to display the various web service wizards. Select the Web Service wizard. Click Next.
  3. Select the following options on the first page of the wizard:
    • Web service type: Top down EJB Web service
    • Service definition: Ensure the ConvertTemperature.wsdl file that you imported is selected.
    • Level of service generation slider: move the slider to Test service. The slider sets the defaults on the remaining wizard pages, but you can override the default settings on each page as you proceed.
    • Service configuration: Ensure that WebSphere Application Server Version 7 or later and the IBM® WebSphere JAX-WS runtime environment are selected. Click Service project and enter TempEJB as your service project name. TempEJBEAR should be selected as your service EAR project.
    • Level of client generation slider: move the slider to Test client.
    • Client configuration: Ensure that WebSphere Application Server Version 7 or later and the IBM WebSphere JAX-WS runtime are selected. The wizard will create a client and client EAR project. You can accept the default names or enter a different name.
    • Monitor the web service.
    Click Next.
  4. On the Web Service Configuration page, leave all the default options selected, and click Next.
  5. On the Router project configuration page, select RouterWebProject as your http router project if it is not already selected, and click Next.
  6. In the Web Service Test page, you can select a test facility to test your web service before a client or proxy is developed. Select Web Services Explorer as the test facility for your web service and click Launch. This step may take several seconds for the WebSphere Application server to start.
  7. The Web Services Explorer is displayed in a Web browser. Select fahrenheitToCelsius or celsiusToFahrenheit from the operations list. Enter a number in the value field and click Go. A trivial implementation of each of these operations is provided, and a default value of -3 is returned. If both operations complete successfully, close the browser window and click Next in the web services wizard.
  8. In the Web Service Client Configuration page, keep the default selections. Click Next.
  9. In the Web Service Client Test page, ensure Test the generated proxy and Run test on server are both selected. In the Methods section. Ensure that all methods are selected, or click Select All to select all methods. Click Finish.
  10. The sample application is launched in a Web browser. You can use this application to test the web service by selecting a method in the Methods frame, entering an input value in the Inputs frame, and clicking Invoke to view the result in the Result frame. Do not close the TestClient.jsp browser window yet - it will be used to test the web service traffic for WS-I compliance later in this tutorial.

Lesson checkpoint

< Previous | Next >
Icon that indicates the type of topic Tutorial lesson topic
Timestamp icon Last updated: July 17, 2017 21:58

File name: tdejb_exercise13.html