如何在 Tomcat 6 上手动部署 Web 服务? [英] How to manually deploy a web service on Tomcat 6?
问题描述
我正在学习如何使用 Java 开发 SOAP 网络服务.
I'm learning how to develop SOAP web services with Java.
到目前为止,我一直在关注这个优秀的教程
So far now I've been following this excellent tutorial
一切顺利,我让我的 Web 服务从命令行使用它的嵌入式服务器工作,然后在 NetBeans 的帮助下我将它部署在 Tomcat 上.
It all goes well, I have my web service working from the command line with it's embedded server and then, with the help of NetBeans I deployed it on Tomcat.
我想知道在 Tomcat 上手动部署它的步骤,以了解它是如何完成的,因为我不喜欢依赖 IDE.
I'd like to know the steps to manually deploy it on Tomcat, in order to learn how it's done and because I don't like depending on an IDE.
我的意思是,我想知道如何通过命令行和文本编辑器完成所有操作.
I mean, I'd like to know how everything could be done from the command line and a text editor.
我还找到了解释如何手动将 servlet 部署到 Tomcat 的链接,
I've also found this link that explains how to manually deploy a servlet to Tomcat,
http://linux-sxs.org/internet_serving/c292.html
但我找不到任何关于如何部署网络服务的文章.
but I couldn't find any article telling how to deploy a web service.
非常感谢.
推荐答案
如何手动构建 jax-ws Web 服务并将其部署到 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/(新 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.
我唯一能实现的方法是用netbeans部署一个web服务,然后在dist.war中查看war生成的文件(它只是一个zip文件,你可以用7zip打开它)
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!!!
测试:
C: omcat6in>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.
问候
sas
// c:javasrcwsAdder.java
package ws;
import javax.jws.WebService;
@WebService
public class Adder {
public double add( double value1, double value2 ) {
return value1 + value2;
}
}
3.站在 c:javasrc 执行
c:javasrc> javac wsAdder.java
file c:javasrcwsAdder.class 会生成
c: omcat6webappsadder_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 c:javasrcwsAdder.class
c: omcat6webappsadder_wsWEB-INFclasseswsAdder.class
<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/adder_ws"/>
7.c: omcat6webappsadder_wsWEB-INFweb.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<listener>
<listener-class>com.sun.xml.ws.transport.http.servlet.WSServletContextListener</listener-class>
</listener>
<servlet>
<servlet-name>Adder</servlet-name>
<servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Adder</servlet-name>
<url-pattern>/add</url-pattern>
</servlet-mapping>
<!-- not needed
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
-->
</web-app>
8.配置WEB-INFsun-jaxws.xml
文件:c: omcat6webappsadder_wsWEB-INFsun-jaxws.xml
8. Config WEB-INFsun-jaxws.xml
file : c: omcat6webappsadder_wsWEB-INFsun-jaxws.xml
<?xml version="1.0" encoding="UTF-8"?>
<endpoints version="2.0" xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime">
<endpoint implementation="ws.Adder" name="Adder" url-pattern="/add"/>
</endpoints>
9.复制库
文件在 c: omcat6webappsadder_wsWEB-INFlib
9. Copy libraries
files at c: omcat6webappsadder_wsWEB-INFlib
复制 netbeans 文件
copy netbeans files from
[netbeans dir]enterprisemodulesextmetro*.*
和
[netbeans dir]idemodulesextjaxbactivation.jar
10.重启apache
关机:c: omcat6inshutdown.bat
10. restart apache
Shutdown : c: omcat6inshutdown.bat
启动:c: omcat6instartup.bat
Startup : c: omcat6instartup.bat
打开 Web 浏览器并转到 http://localhost:8080/adder_ws/add?wsdl
您还可以使用诸如soapui(http://www.soapui.org/)之类的工具来测试网络服务
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...
这篇关于如何在 Tomcat 6 上手动部署 Web 服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!