Creating the web service implementation class, Creating the deployment descriptor – HP Integrity NonStop J-Series User Manual

Page 320

Advertising
background image

Developing TemperatureConverter Web Service on Windows

Developing the TemperatureConverter web service on a Windows system involves the following
activities:

1.

“Creating the Web Service Implementation Class” (page 320)

2.

“Creating the Deployment Descriptor” (page 320)

3.

“Creating an Axis2/Java AAR File” (page 321)

Creating the Web Service Implementation Class

To create the Web Service implementation class, complete the following steps:

1.

Create the TemperatureConverter sub-directory in <My SASH
Home
>\axis2\gettingstarted directory

on your Windows system.

2.

Create a Java class TemperatureConverter.java in the TemperatureConverter
directory using any text editor.

3.

Modify the TemperatureConverter.java class to implement c2fConversion and
f2cConversion

(to convert Celsius to Fahrenheit and Fahrenheit to Celsius respectively)

methods.

After incorporating these two methods, the TemperatureConverter.java class appears
as follows:

/**
* Temperature Converter Implementation Class
*/
public class TemperatureConverter {
/**
* util method to convert celsius to fahrenheit
* @param cValue : double value of celsius
* @return calculated value of fahrenheit
*/
public double c2fConversion(double cValue) {
return ((cValue * 9.0)/5.0 )+ 32.0;
}

/**
* util method to convert fahrenheit to celsius
* @param fValue : double value of fahrenheit
* @return calculated value of celsius
*/
public double f2cConversion(double fValue) {
return ((fValue - 32.0) * 5.0) / 9.0;
}
}

Compile the TemperatureConverter.java class using the following steps:
a.

Go to the TemperatureConverter directory using the command:

command prompt> cd <My SASH Home>\axis2\gettingstarted\TemperatureConverter

b.

Compile TemperatureConverter.java using the command:

command prompt> javac TemperatureConverter.java

The TemperatureConverter.class file is created in the TemperatureConverter
directory.

Creating the Deployment Descriptor

The services.xml file is the deployment descriptor for any web service deployed under
Axis2/Java. The service deployment descriptor is used by the deployment module to configure
and deploy the service. Therefore, it is essential to reference TemperatureConverter as a web
service in the services.xml file to deploy it in Axis2/Java.

320 Getting Started with Axis2/Java

Advertising
This manual is related to the following products: