How to manually deploy a web service on Tomcat 6?

后端 未结 5 1960
无人及你
无人及你 2020-12-02 11:46

I\'m learning how to develop SOAP web services with Java.

So far now I\'ve been following this excellent tutorial

http://web.archive.org/web/20120626005333/h

5条回答
  •  执笔经年
    2020-12-02 11:51

    How to MANUALLY build and deploy a jax-ws web service to tomcat

    I was trying to figure out how to MANUALLY build and deploy a web service for learning pourposes.

    I began with this excellent article

    http://java.sun.com/developer/technicalArticles/J2SE/jax_ws_2/ (new URL: http://www.oracle.com/technetwork/articles/javase/jax-ws-2-141894.html)

    The idea was to do the whole thing using only a notepad and the command line.

    The only way I could achieve was by deploying a web service with netbeans, and then having a look at the war generated file at \dist\.war (it's just a zip file, you can open it with 7zip)

    I leave this in case anybody is interested and for documentation purposes...

    If anybody knows an easier way please let me know!!!

    tested on:

    C:\tomcat6\bin>version
    Server version: Apache Tomcat/6.0.26
    Server built:   March 9 2010 1805
    Server number:  6.0.26.0
    OS Name:        Windows XP
    OS Version:     5.1
    Architecture:   x86
    JVM Version:    1.6.0_18-b07
    JVM Vendor:     Sun Microsystems Inc.
    

    saludos

    sas

    1. create the following dir c:\java\src\ws

    2. create thew following file c:\java\src\ws\Adder.java

    // c:\java\src\ws\Adder.java
    package ws;
    import javax.jws.WebService;
    
    @WebService
    public class Adder {
     public double add( double value1, double value2 ) {
      return value1 + value2;
     }
    }
    

    3. standing at c:\java\src\ execute

    c:\java\src> javac ws\Adder.java
    

    file c:\java\src\ws\Adder.class will be generated

    4. create the following directory structure with the following files

    c:\tomcat6\webapps\adder_ws
    
    META-INF
      context.xml
    WEB-INF
      classes
        ws
          Adder.class
      lib
        activation.jar
        webservices-api.jar
        webservices-extra.jar
        webservices-extra-api.jar
        webservices-rt.jar
        webservices-tools.jar
      sun-jaxws.xml
      web.xml
    

    5. copy compiled file

    copy c:\java\src\ws\Adder.class c:\tomcat6\webapps\adder_ws\WEB-INF\classes\ws\Adder.class

    6. c:\tomcat6\webapps\adder_ws\META-INF\context.xml

    
    
    

    7. c:\tomcat6\webapps\adder_ws\WEB-INF\web.xml

    
    
        
            com.sun.xml.ws.transport.http.servlet.WSServletContextListener
        
        
            Adder
            com.sun.xml.ws.transport.http.servlet.WSServlet
            1
        
        
            Adder
            /add
        
    
    
    

    8. Config WEB-INF\sun-jaxws.xml

    file : c:\tomcat6\webapps\adder_ws\WEB-INF\sun-jaxws.xml

    
    
      
    
    

    9. Copy libraries

    files at c:\tomcat6\webapps\adder_ws\WEB-INF\lib

    copy netbeans files from

    [netbeans dir]\enterprise\modules\ext\metro\*.*
    

    and

    [netbeans dir]\ide\modules\ext\jaxb\activation.jar
    

    10. restart apache

    Shutdown : c:\tomcat6\bin\shutdown.bat

    Startup : c:\tomcat6\bin\startup.bat

    11. Test

    Open a web browser and go to http://localhost:8080/adder_ws/add?wsdl you can also use a tool like soapui (http://www.soapui.org/) to test the web service

    that's it, I guess now I'll have a look at the way eclipses does it...

提交回复
热议问题