< Previous | Next >

Lesson 1.4: Implement the temperature conversion methods

Before you begin, you must complete Lesson 1.3: Create the Web service.
Trivial implementations of the fahrenheitToCelsius and celsiusToFahrenheit methods were automatically generated when you created a Web service from your WSDL document. In this section you will replace these trivial implementations with more meaningful code, and perform the necessary steps to test your new methods.
  1. In the Project Explorer view, select ConvertTemperatureSoapBindingImpl.java under TempEJB > ejbModule > sample.
  2. Locate the fahrenheitToCelsius method and replace the current implementation with the following: return (fahrenheitValue - 32) / 9 * 5;
  3. Locate the celsiusToFahrenheit method and replace the current implementation with the following: return (celsiusValue * 9 / 5) + 32;
    Temperature conversion
  4. Save your updates by clicking File > Save.
  5. Restart the EAR by expanding WebSphere v6.1 Server in the Servers view and right-clicking TempEJBEAR > Restart TempEJBEAR.
  6. Click Run > Launch the Web Services Explorer from the main menu bar and repeat the instructions from the previous section to test your fahrenheitToCelsius and celsiusToFahrenheit methods.

Lesson checkpoint

< Previous | Next >