<! --
@ Page {margin: 2 cm}
P {margin-bottom: 0.21}
-->
Use eclipse to generate a WebService Application
1. Create a dynamic
WEB Project
2. Create a class that provides external services. For example:
Package
Com. guorui. Services;
Public
Class
CalculateService
{
/**
*//**
*
Addition operation
*
@ Param
X Increment
*
@ Param
Y Addition
*
@ Return
Sum of X and Y
*/
Public
Float
Plus (Float
X,Float
Y ){
Return
X + Y;
}
/**
*//**
*
Subtraction
*
@ Param
X subtrahend
*
@ Param
Y
*
@ Return
Difference between x and y
*/
Public
Float
Minus (Float
X,Float
Y ){
Return
X-y;
}
/**
*//**
*
Multiplication
*
@ Param
X Multiplier
*
@ Param
Y Multiplier
*
@ Return
Product of x and y
*/
Public
Float
Multiply (Float
X,Float
Y ){
Return
X * y;
}
/**
*//**
*
Division
*
@ Param
X dividend
*
@ Param
Y Divisor
*
@ Return
Vendors of x and y
*/
Public
Float
Divide (Float
X,Float
Y ){
Return
X/y;
}
}
3. Create a webservice Application
4. next
To finish
5. Call Method
CalculateServiceProxy
Csp =New
CalculateServiceProxy ("http: /localhost: 8080/wstest/services/CalculateService ");
Try
{
System.Out. Println (csp. plus (100,
23 ));
}
Catch
(Exception e ){
//
TODO:
Handle exception
}