常用框架发布WbService.docVIP

  • 3
  • 0
  • 约1.21万字
  • 约 10页
  • 2016-10-17 发布于贵州
  • 举报
常用框架发布WbService

使用Xfire、Axis、Axis2框架实现WebService 一、用xfire发布WebService 1、完成接口、实现类以及相关的bean代码编写 本示例中用到的接口、实现类、bean如下: 接口: @WebService(name = HellowWord, targetNamespace = http://webserviceDemo/schema/HelloWord/) @SOAPBinding(use = SOAPBinding.Use.LITERAL, parameterStyle = SOAPBinding.ParameterStyle.WRAPPED) public interface HellowWord { @WebMethod(operationName = sayHellow, action = ) public void sayHellow( @WebParam(name = user, targetNamespace = ) User user); @WebMethod(operationName = sayAllHellow, action = ) public void sayAllHellow( @WebParam(name = users, targetNamespace = ) ListUser users); } 实现类: @WebService(name = HellowWord, targetNamespace = http://webserviceDemo/schema/HelloWord/) public class HelloWordImpl implements HellowWord { public void sayAllHellow(ListUser users) { if (null == users || users.size() = 0) { System.out.println(No people!); } for (User user : users) { System.out.println(user.getUserName() + hellow!); } } public void sayHellow(User user) { if (null == user) { System.out.println(No people!); } System.out.println(user.getUserName() + hellow!); } } 使用到的自定义bean: public class User { private String userName; private int age; private String gender; // get\set方法略 } 2、导入Xfire相关jar包 将已下载的相关xfire所有jar包导入工程(jar包没有按功能区分,有兴趣可以自己研究),本工程的导入方式为,在工程的最上层目录下新建一个lib/xfire目录,将相关jar包拷入该目录,本工程是用Eclips开发的,所以将本工程的.settings/ponent中添加上wb-resource deploy-path=/WEB-INF/lib source-path=/lib/xfire/,最后执行导入工作,这样做有助于对工程不同功能的jar包进行管理。 3、添加xfire的配置文件 配置文件添加方法一: 在工程的src目录下新建META-INF\xfire\services.xml文件。 配置文件添加方法二: 该方法可以让工程的结构层次更清晰,在工程的最上层目录下新建conf\META-INF\xfire\services.xml文件,然后将conf目录下的内容设置为编译至WebRoot\WEB-INF\classes目录下即可,其实不论配置文件放在什么地方只要工程编译完成后,在WebRoot\WEB-INF\classes目录中有META-INF\xfire\services.xml即可。 4、完成services.xml配置 本工程配置示例: ?xml version=1.0 encoding=UTF-8? beans xmln

文档评论(0)

1亿VIP精品文档

相关文档