< Previous | Next >

Lesson 1.3: Create the Web service

Before you begin, you must complete Lesson 1.2: Import and validate the WSDL file.
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.
To start the server, right-click the server in the Servers view and select Start:
WebSphere Application Server in the Servers view
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.

When you have completed testing, you can publish your Web service to a UDDI Business Registry using the Export wizard.
  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.
    • Service configuration: ensure that WebSphere v6.1 Server and the IBM WebSphere JAX-RPC 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 v6.1 Server and the IBM WebSphere JAX-RPC 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.

    Once you have selected the correct options the wizard should look similar to the following:

    Creating a top down EJB Web service - wizard first page with correct options selected
    Click Next.

  4. On the Web Service Skeleton EJB Configuration page, select RouterWebProject as your router project if it is not already selected.
  5. 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.
  6. 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.
  7. In the Web Service Proxy page, keep the Security Configuration selection at No Security to remain WS-I compliant. Click Next.
  8. 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. If you want to publish your Web service to a UDDI Registry, click Next to configure the Web Service Publication options. However this step will not be covered in this tutorial. Otherwise, click Finish.
  9. 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 >