接下來修改web.xml如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems,
Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_3.dtd">
<web-app>
<listener>
<listener-class>
com.sun.xml.ws.transport.http.servlet.WSServletContextListener
</listener-class>
</listener>
<servlet>
<servlet-name>hello</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>hello</servlet-name>
<url-pattern>/hello</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>120</session-timeout>
</session-config>
</web-app>
要部署的 web 服務應用程序,我們需要 sun-jaxws.xml 配置文件,這個文件的內容如下:
<?xml version="1.0" encoding="UTF-8"?>
<endpoints
xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime"
version="2.0">
<endpoint
name="HelloWorld"
implementation="com.yiibai.ws.HelloWorldImpl"
url-pattern="/hello"/>
</endpoints>
現(xiàn)在,所有文件都準備好目錄結構看起來會像下面的圖片:
現(xiàn)在,這個應用程序創(chuàng)建一個WAR文件。選擇 project > right click > Export > WAR文件。hello.war 文件保存Tomcat 服務器 webapps文件夾下,F(xiàn)在啟動Tomcat服務器。在服務器啟動后,你應該能夠訪問web服務可以通過以下網(wǎng)址:
http://localhost:8080/hello/hello