axis2+springMVC+hibernate整合示例

最近有个项目,需要和第三方系统做数据交换,于是打算采用web service这一成熟技术来实现这种需求,而axis2就很适合用来做web service的接口发布容器。

下面说下整个架构的思路,采用axis2+springmvc+hibernate这三大主流框架:





1.src目录
  core:基础框架类,提供基本的增删改查操作;
  user:业务实体类,用于业务的一些操作:比如登录,新增和删除;
  webservice:提供了client和service(开发核心);其中client用于webservice接口的调用测试,service用于开发web service接口。

2.axis2-web目录:管理目前axis2容器中的所有接口服务

3.web-inf目录
  conf:axis2.xml(暂时用不上);
  lib:存放整个工程的jar(如果用maven会更加方便管理jar);
  modules:axis2模块化(暂时用不上);
  service(核心):services.xml中定义了你所要发布的接口路径和对外开放的方法接口(即对应src目录中的webservice包下的service类定义);
 
4.spring-servlet.xml整合axis2
<!--与axis2的整合,配置 applicationContext与对外开放的service-->
<bean id="applicationContext" class="org.apache.axis2.extensions.spring.receivers.ApplicationContextHolder" />
<bean id="springWsServerService" class="com.kimho.webservice.service.SpringWsServerService"></bean>

5.web.xml整合axis2:
<servlet>
        <servlet-name>AxisServlet</servlet-name>
        <display-name>Apache-Axis Servlet</display-name>
        <servlet-class>org.apache.axis2.transport.http.AxisServlet</servlet-class>
        <load-on-startup>2</load-on-startup>
</servlet>
<servlet>
        <servlet-name>AxisAdminServlet</servlet-name>
        <display-name>Apache-Axis AxisAdmin Servlet (Web Admin)</display-name>
        <servlet-class>
            org.apache.axis2.webapp.AxisAdminServlet</servlet-class>
</servlet>

到此,整个工程搭建完毕,运行下,可以看到axis2目前拥有的接口服务:



注:整个工程源码请在附件处下载(采用了分卷压缩)。

猜你喜欢

转载自kimho.iteye.com/blog/2242948