【IT168 技术】
eclipse下新建webapp项目
此WebService服务由Axis实现,样例项目所需要jar包及目录:
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/dtd/web-app_2_3.dtd">
<web-app>
<display-name>Apache-Axis</display-name>
<!--实际servlet程序,这里是AxisServlet-->
<servlet>
<servlet-name>AxisServlet</servlet-name>
<display-name>Apache-Axis Servlet</display-name>
<servlet-class>
org.apache.axis.transport.http.AxisServlet
</servlet-class>
</servlet>
<!-- 定义servlet和url的对应关系-->
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
</web-app>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web
Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>Apache-Axis</display-name>
<!--实际servlet程序,这里是AxisServlet-->
<servlet>
<servlet-name>AxisServlet</servlet-name>
<display-name>Apache-Axis Servlet</display-name>
<servlet-class>
org.apache.axis.transport.http.AxisServlet
</servlet-class>
</servlet>
<!-- 定义servlet和url的对应关系-->
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
</web-app>
WebService服务:
package com.archie.service;
/**
* 服务MyService
* @author archie
*
* since 2011-7-13 下午02:34:57
*/
public class SayHelloService {
/**
* 输出List集中字符串
* @return
*/
public String SayHello2WS(String name){ return "Hello,WebService!"+"_____by"+"\t"+name;
}
}
/**
* 服务MyService
* @author archie
*
* since 2011-7-13 下午02:34:57
*/
public class SayHelloService {
/**
* 输出List集中字符串
* @return
*/
public String SayHello2WS(String name){ return "Hello,WebService!"+"_____by"+"\t"+name;
}
}