加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

【WebService学习过程记录(三)】XFire开发Web Service---HelloWo

发布时间:2020-12-16 22:04:49 所属栏目:安全 来源:网络整理
导读:一、前期准备: 1、tomcat 版本:Tomcat 7.x 下载地址:??http://tomcat.apache.org/download-70.cgi#7.0.23 2、Xfire 版本:xfire-distribution-1.2.6 下载地址:http://xfire.codehaus.org/Download 3、eclipse 二、在tomcat下面配置xfire 1、在tomcat的we
一、前期准备:
1、tomcat
版本:Tomcat 7.x
下载地址:??http://tomcat.apache.org/download-70.cgi#7.0.23
2、Xfire
版本:xfire-distribution-1.2.6
下载地址:http://xfire.codehaus.org/Download
3、eclipse
二、在tomcat下面配置xfire
1、在tomcat的webapp文件夹下按如下目录新建文件或者文件夹:
xfire
? |--WEB-INF
??? |--lib
??? |--web.xml
??? |--classes
???? ?? |--META-INF
??????????? |--xfire?
??????????????? |--services.xml

2、将xfire-1.2.6/lib下面的内容拷贝到xfire/WEB-INF/lib目录中
3、将xfire-1.2.6/xfire-all-1.2.6.jar拷贝到webapps/xfire/WEB-INF/lib目录中
4、web.xml文件内容

[html]? view plain ?copy
?print ?
  1. <!--?START?SNIPPET:?webxml?-->????
  2. <!DOCTYPE?web-app????
  3. ????PUBLIC?"-//Sun?Microsystems,?Inc.//DTD?Web?Application?2.3//EN"????
  4. ????"http://java.sun.com/dtd/web-app_2_3.dtd">????
  5. <web-app>?????
  6. ??servlet????servlet-name>XFireServlet</>????
  7. display-name>XFire?Servletservlet-class????????org.codehaus.xfire.transport.http.XFireConfigurableServlet????
  8. ????
  9. servlet-mappingurl-pattern>/servlet/XFireServlet/*????
  10. >/services/*>????

5、services.xml文件内容

copy
?<!--?START?SNIPPET:?services?-->??
  • beans?xmlns="http://xfire.codehaus.org/config/1.0">??
  • beans<!--?END?SNIPPET:?services?-->??
  • 6、启动tomcat应用服务器;打开浏览器;访问如下的网址:

    http://localhost:8080/xfire/services/?

    (8080是tomcat端口号?? http://localhost:端口号/项目名称/services/)

    如能正确的显示成功页面,说明我们的xfire配置成功了


    三、Helloword开发
    1、eclipse中建立项目XfireTest
    2、新建HelloService.java文件
    [java]? view plain ?copy
    ?print ?
      package?com.rwq.test;??
    1. ??
    2. public?class?HelloService?{??
    3. ????public?String?sayHello(String?name){??
    4. ????????return?name+",你好!";??
    5. ????}??
    6. }??
    3、service.xml
    [html]? copy
    ??
      <!--?START?SNIPPET:?services?-->??
    1. >??
    2. service>??
    3. name>HelloService??????namespace>http://com.rwq.testDemo/HelloServiceserviceClass>com.rwq.test.HelloService<!--?END?SNIPPET:?services?-->??
    4、将编译后的HelloService.class文件和service.xml文件部署到tomcat中
    注意HelloService.class在xfire/WEB-INF/classes/com/rwq/test/HelloService.class;
    5、正确启动tomcat之后,在浏览器输入: http://localhost:/xfire/services/
    6、出现如下的页面



    四、如果是直接在eclipse中部署发布:
    目录结构如下


    文件内容如上,
    启动tomcat,浏览器输入:http://localhost:端口号/项目名称/services/
    五、eclipse自带的WebService浏览器测试



    (编辑:李大同)

    【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

      推荐文章
        热点阅读