Overblog Tous les blogs Top blogs Technologie & Science Tous les blogs Technologie & Science
Editer l'article Suivre ce blog Administration + Créer mon blog
MENU

HelloWorld service deployment. Eclipse and Tomcat

10 Mars 2013 Publié dans #apache, #tomcat, #webservice, #java

refer : http://www-inf.it-sudparis.eu/~nguyen_n/teaching_assistant/web_services/simple_web_service_deployment_with_eclipse_and_tomcat_server

Setting up Tomcat on Eclipse

  1. Download and extract Tomcat (suppose version 7.0.12) on your machine.
  2. Open the server view on Eclipse by the menu Windows→Show View→Other→Servers.
  3. Right click on the Server view select New→Server. Let the Server's host name is localhost, select the Server type is Apache→Tomcat v7.0 Server. Click Next.
  4. Specify the installation directory, such as C:\Program Files\Apache Software Foundation\Tomcat 7.0. Click Finish.
  5. You can test the server by clicking on the Start and Stop button at the Server view. You can also reconfigure the server by selecting Windows→Preferences→Server→Runtime Environments.

HelloWorld service deployment

  1. Create a Dynamic Web project named WS_HelloWorld by selecting File→New→Dynamic Web Project. Keep the Target Runtime is Apache Tomcat v7.0 and click Finish.
  2. Open the WS_HelloWorld project, right click on the Java Resources directory, select New→Package. Name it as tps.ws.deployment. Click Finish.
  3. Create a Java class under the package tps.ws.deployment named HelloWorld.
  4. In the HelloWorld class, create the function sayHello which returns the string “Hello ”+input.

    package tps.ws.deployment;

    public class HelloWorld {
    public String sayHello(String input){
    return "Hello "+input;
    }
    }
  5. Right click on the HelloWorld class, select Web Sevices→Create Web service. Verify the Configuration and click Next.
  6. Select the function sayHello and click Finish.
  7. The WS skeleton is automatically generate, the service is automatically published on the Eclipse's Tomcat server, and the Tomcat server automatically run.
  8. A WSDL file is also generated in the WebContent→wsdl folder. We can test our service by right click on this file, select Web Services→Test with Web Services Explorer. Select the sayHello operation and type something in the input. You will see the result like the following:
Publicité
Partager cet article
Repost0
Pour être informé des derniers articles, inscrivez vous :
Commenter cet article