1、下载
a.下载xfire()
2、部署
a.解压xfire,将lib目录下所有的jar添加到web-inf/lib目录下
下面是我的工程:
b、编写web.xml目录
View Code
XFireServlet org.codehaus.xfire.transport.http.XFireConfigurableServlet XFireServlet /servlet/XFireServlet/* XFireServlet /services/*
c、编写接口文件
View Code
package org.study.webservice.inf;import java.util.List;public interface IWebService { public ListsearchString(String key); public String sayHello(String name);}
d、编写具体的实现类
View Code
package org.study.webservice.impl;import java.util.ArrayList;import java.util.List;import org.study.webservice.inf.IWebService;public class WebServiceImpl implements IWebService { public ListsearchString(String key) { List arrayList = new ArrayList (); arrayList.add("aa"); arrayList.add("bb"); arrayList.add("cc"); return arrayList; } public String sayHello(String name) { return name + ",你好,this is my first webservice xfire demo."; }}
e、在WebRoot/META-INF目录下新建xfire文件夹,并在xfire文件夹下新建services.xml文件,内容如下:
View Code
xfireService http://localhost:10086/webServiceDemo/xfireService org.study.webservice.inf.IWebService org.study.webservice.impl.WebServiceImpl
f、将工程部署到tomcat目录下,并将META-INF复制一份到WEB-INF/classes目录下
到现在为止,整个webservice已部署成功,启动tomcat服务,访问