Create a simple webservice with java


Hello ,

In This article , we gonna to see how to create a simple web service . like a operation , or to give you a result like TOTO . And after we will see in the futur a web service which  contains  a management of an  data base .



First : 
Create a web application with eclipse :
1-choose  to create a dynamic web project :




2-In this example , We choose the next name :


3-After That we click in finish .

The Eclipse IDE ,has generated to us the package and the folders .
We locate in the package : src and we create a new package :   com.formation.webservice
After creating the package , create a class (in this example we choose the name WebTuto) :



So , what do we see in this class ?
2 method (one int and the other String )

Second :
After creating the class in the Web Application , We have now to generate the webservice . How ?

-Go to the project and click into the class WebTuto and click to display the menu,
     After that choose the menu Webservice --> Create a web service
-You will receive a  window like this :
In Fact , in this window , are some parametre to change or to let :

1-Server runtime :  you can choose here the server to deploy in it the webservice

2-Web service runtime : you can choose the type of the runtime ( in this example we choose apache Axis)
    we will see soon , a tutorial about "Apache Axis".
3-Service Project :The project which contains the web service .
4-Service Implementation : is the class with all his method,  wich be transform to a webservice.
The progresse Bar is indicated to Start Service, Let's each other parts in this bar :

Level 1 : Develop service.
Level 2 : Assemble service.
Level 3 : Deploy  service.
Level 4 : Install service.
Level 5 : Start service.
Level 6 : Test service.
(in the next chapiters we zoom in this part for more information about it )

After clicking in Finish  , we get other component like a folder named wsdl , when you open this folder you get an WSDL file ( Web Service Description Langage ) and  other component .

Finally :
Now , we want to test this web service :
-Choose  a menu webservice and click in Test with Web service Explorer , you get a window like this :


Click in  the method wich you like to Test , and enter the adequat parameter , to get the result .