Tuesday, May 12, 2009

Creating a simple HelloWorld JAX-WS Webservice using Eclipse

I'm using Glassfish Tools Bundle for Eclipse in this example. You can download it from here

1. Create a new Dynamic Web Project and give it a name eg. HelloWorldService



2. Ensure Target Runtime is Glassfish V3 Prelude


3. Choose the default settings for the Web Module Page


4. Select your new project and create a new class



5. Name it HelloWorld. Name the package sample and click on Finish button


6. Enter the code below
package sample;

import javax.jws.WebService;

@WebService
public class HelloWorld {

public String hello(String param) {
return param + ", World";
}


}



7. Deploy the service by selecting the project and select Run as>Run on server.



8. Choose default settings when the Run on server window appears



9. You will see the default jsp page displayed.


10. Right click on your project. Select New->Web Service (you'll probably need to choose "other" and find it in the full list). Go through the configuration stages. Eclipse will produce all the required stuff.









11. Start the server (if it hasn't started). If, for example, the app server port is 8080, the project URL you chose is HelloWorldService, and the class name is HelloWorld?, open a web browser and go to http://localhost:8080/HelloWorldService/services/HelloWorld?wsdll, and you should see the WSDL description.



And we are done! :-)

No comments:

Post a Comment