Exercise 1.4: Implement the temperature conversion methods

Before you begin, you must complete Exercise 1.3: Create the Web service.

Implementing the temperature conversion methods (optional)

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. Switch to the resource perspective if you are not already using it.
  2. In the Navigator view, select ConvertTemperatureSoapBindingImpl.java under TempEJB > ejbModule > samples.
  3. Locate the fahrenheitToCelsius method and replace the current implementation with the following: return (fahrenheitValue - 32) / 9 * 5;
  4. Locate the celsiusToFahrenheit method and replace the current implementation with the following: return (celsiusValue * 9 / 5) + 32; Image of the updated celsiusToFahrenheit and fahrenheitToCelsius methods.
  5. Save your updates by clicking File > Save.
  6. Restart the EAR by right-clicking WebSphere Application Server v6.0 in the Server view and clicking Restart project > TempEAR.
  7. 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.

Now you are ready to begin Exercise 1.5: Validate the Web service traffic WS-I compliance.

Terms of use | Feedback
(C) Copyright IBM Corporation 2000, 2004. All Rights Reserved.