Development of a Web service (Client + Server): calculation of the different integer operation integers
Web service development
Proceeding as previously (Hello World exercise), you are asked to define a web service that calculates the square and the double of a number and the sum multiplication, and the division of two intgers.
The service returns this time a number. The method to be invoked has a parameter.
To process methods with parameters, suppose your service has the
computeSquare method with the following signature:
public class SquareDouble{
public int computeSquare (int nb) {
return nb * nb;
}
// fininsh the other operations
}
Assuming that your service is called SquareWorldService, the invocation will then be carried out as follows:
http://localhost:8080/axis2/services/SquareWorldService/computeSquare?args0=10
You will get the following response (still in SOAP XML format), here is an excerpt:
<soapenv: Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance ">
<soapenv: Body>
<calculateResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<calculateReturn xsi:type="xsd:int"> 100 </calculeReturn>
</calculeResponse>
</soapenv:Body>
</soapenv:Envelope>
Client development
Develop a java client as before (Hello World exercise) or Servlet which gives the square, the double, the addition, multiplication, sous traction and division of integers.
Back to top