MyEclipse下开发Web Service(转)

http://hi.baidu.com/banseon/blog/item/6cf5e2133e0535005baf53d2.html
本文介绍了使用MyEclipse Web Service来迅速开发和测试一个HelloWorld Web Service,其中包括:
     1. 介绍了MyEclipse Web Services的基本概念
     2. 创建一个MyEclipse Web Services工程
     3. 创建一个简单的HelloWorld Web Service
     4. 在Web容器中,如Tomcat 5中部署Web Service
     5. 使用Web Services Explorer来测试部署的Web Services

     XFire Java SOAP框架概述
     MyEclipse Web Services是建立在XFire Java SOAP框架和工具基础上的, XFire是一款开源的Java SOAP框架。它拥有一个轻量级的信息处理模块,通过STAX来与SOAP信息相结合。提供了一个工作在Web Services下的简单API,支持POJO和schema开发. XFire支持 Web Services standards,Spring 整合, 支持JBI , 支持 JAXB ,XMLBeans,Java 5 和JAX-WS.并支持HTTP, JMS, XMPP, In-memory传输协议.

    一. 创建Web Service工程

     在MyEclipse 5.0中引入了一个新的工程类型即Web Service工程,该工程扩展了MyEclipse Web Project来支持额外的Web Service配置,开发和部署.本部分将使用Web Services Project wizard来创建和配置一个新的Web Service Projects Web Service Wizard将完成下列的动作:
     创建MyEclipse J2EE Web Project
     在工程中的web.xml文件中配置XFire Servlet
     创建XFire services.xml配置文件
     在工程中的构建路径中添加MyEclipse-XFire类库
     添加一个指定的MyEclipse web project builder到.projects文件,以便部署services.xml文件到它合适的位置.如: <webroot>/WEB-INF/classes/META-INF/xfire/

     运行Web Service Project Wizard
     该向导包括三个页面, Page-1搜集Web Project配置细节, Page-2搜集XFire配置细节, Page-3在新建的构建路径中配置XFire类库
     1. 执行Web Services Project Wizard.
        1). 选择File>New>Other
        2). 扩展MyEclipse种类按照J2EE工程的种类
        3). 选择Web Services Project然后点击Next,如图所示


     Figure-1: New Project Wizard Launcher
     2. 添加Project Name,点击Next


     Figure-2: Page-2, Collecting web configuration details
     3.在向导的Page-2中添加XFire servlet和service.xml文件的配置信息,按照默认的值即可.


     Figure-3: XFire servlet and services.xml configuration

4.在向导的Page-3中选择类库添加到工程的构建路径中,其中XFire Core Library是需要的,如果要在工程中开发一个客户端应用, XFire HTTP Client Libraries也是需要的.


     Figure-4: Selecting XFire libraries to add to new web service project buildpath

     5选择Finish完成Web Service工程的创建过程
     Figure-5,显示了新创建的HelloWorld Web Service工程的组织结构,Web Service 工程和一个标准的MyEclipse Web工程很相似. XFire Web Service配置元素如图红色区域显示:


     Figure-5: Web services artifacts of a new web service project

    二. 创建Web Service-Code-first Strategy
     在这部分将用MyEclipse Web Service Wizard并通过使用Code-first Strategy来创建一个HelloWorldService示例.

     1. 执行MyEclipse Web Service Wizard,有两种方法来执行MyEclipse Web Service Wizard
     方法1.从MyEclipse perspective toolbar中来执行向导
     在打开的Web Service Wizard上的workbench上来选择新Web Service按钮
     方法2.从workbench menubar执行向导
     1. 从workbench menubar选择: File>New>Other>MyEclipse>Web Service


     Figure-6: Launching Web Service Wizard

     2. 在Page-1选择HelloWorld 工程并选择Create web service from Java bean
     3. 选择Next到Page-2


posted @ 2007-08-27 17:50  jambol  阅读(2099)  评论(1编辑  收藏  举报