< Previous | Next >

Lesson 1.3: Finding a Web service and creating a Web service proxy

Provide a short description for this tutorial lesson.

Before you begin, you must complete Lesson 1.2: Create a Faces JSP file.

You must now locate a Web service for which you want to create a client. This Web service can be on a private or public UDDI registry, at a URL, or in your workspace. For this tutorial, we will search for a Web service that returns the temperature for a given zip code that is provided by www.xmethods.com.

You can find a Web service and create a proxy for the Web service using the Web Service Discovery wizard:

  1. On the Palette select the Data tab. Select Web Service, right-click and click Insert. Note that you need to be in the Web perspective to see the Palette.
  2. Select Web services from a known URL. Although we know the URL for the WSDL file, by using a Web Service Inspection Language (WSIL) file you can search all the Web services which are available. WSIL files are frequently found at a location similar to the following: http://www.web_service_provider.com/inspection.wsil
  3. Enter the following WSDL URL in the URL field: http://www.xmethods.net/sd/2001/DemoTemperatureService.wsdl and click Go.
  4. The Web service we have selected is now displayed in the table. Click Port: TemperaturePort to select it.
    Web Services Discovery Dialog with WSDL details visible
    To test the Web service, click Details to launch the Web service in the Web Services Explorer. For more information about using the Web Services Explorer, refer to the online help.
  5. Once you have tested the Web service, click Add to Project. If you are prompted to overwrite files on your system click Yes to All.
  6. The Web service you selected is now listed in the list of existing Web services. When you select it the only method available for this Web service is listed in the methods list. Click Finish to add it to your JSP.

The proxy should now be shown in the Page Data view. If the Page Data view is not displayed you can open it by clicking Window > Show View > Page Data:

Proxy displayed in Page Data view

Additionally, the method and the action to invoke it have been added to the JSP file. It should look similar to the following:

WSProxy.jsp with method and submit button added

Running the proxy on the server

  1. Save WSProxy.jsp by clicking File > Save. Close the WSProxy.jsp editor.
  2. In the Project Navigator, right-click WSProxy.jsp and click Run > Run on Server.
  3. Select the server that is associated with the dynamic Web project, and click Finish. If you want to run the Faces JSP on another server, you would need to re-target the Web project that you created to the new server.
Once the JSP is running on the server, it should open in a Web browser in the workspace. You can test the Web service by entering a valid value in the zip code field and clicking Submit. Note that this service currently only returns the hard-coded value of 52 rather than the actual temperature of the zip code you entered.

Lesson checkpoint

Finish your tutorial by reviewing the materials in the Summary.

Feedback

< Previous | Next >