You are on page 1of 3

Aim: Write a program to implement to create a simple web service that converts the temperature from

Fahrenheit to Celsius (using HTTP Post Protocol)

Task to be done:
1. First create a project with name TempConverter
2. Create a package ‘com.me.temperature’
3. Open package create web application TempConvertWS.java

Algorithm/Flowchart :
1. Open web app in browser.
2. Take user input either degree or Fahrenheit value
3. Press Enter to display the output/result.
4. Code for experiment/practical:

Implementation Code:
package org.me.temperature.
import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;

/**
*
* @author Jitu
*/
@WebService(serviceName = "TempConvertWS")
public class TempConvertWS {

/**
* This is a sample web service operation
* @param faren
* @return
*/
@WebMethod(operationName = "FtoC")
public float hello(@WebParam(name = "hello")float faren) {
float cel =(float)5/9*(faren-32);
return cel;
}

/**
* Web service operation
* @param cel
* @return
*/
@WebMethod(operationName = "CtoF")
public float hello2(@WebParam(name = "hello1") float cel) {
//TODO write your implementation code here:
float fah = (float)(cel*9)/5+32;
return fah;
}}

Output:
Fahrenheit to Celcius: Celcius to Fahrenheit:
Formula : float cel =(float)5/9*(faren-32); Formula: float fah = (float)(cel*9)/5+32;

Learning outcomes (What I have learnt):


In second experiment of web security lab I was exposed to creating web application to convert
temperature from celcius to Fahrenheit and vice-versa.

You might also like