spring与axis2 1.6.2整合

网上介绍spring和axis2的文章已经不少了,我在这里就不再谈论了.直接整合了.

1.整合项目的整体结构


2,主要的配置文件

<span style="color:#FF0000;"><strong>(1),spring配置文件</strong></span>

</strong></span><?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
            http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
            http://www.springframework.org/schema/context
            http://www.springframework.org/schema/context/spring-context-3.0.xsd
            http://www.springframework.org/schema/tx
            http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
            http://www.springframework.org/schema/aop
            http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
          
         <!-- 使spring管理axis2 的配置 -->
         <bean id="applicationContext"
            class="org.apache.axis2.extensions.spring.receivers.ApplicationContextHolder" />

         <!--对外暴漏的接口类--->
          <bean id="testService"
            class=" com.wondersgroup.axis2.test.InterfaceImpl" />               
</beans>

<span style="color:#FF0000;"><strong>(2),services.xml配置文件</strong></span>
<?xml version="1.0" encoding="UTF-8"?>
<!--LessonAction 是webService 访问的 wsdl  如 localhost:8080/../LessonAction?wsdl -->
 <service name="LessonAction"> 
  
    <description>Spring aware </description> 

    <parameter name="ServiceObjectSupplier"> 
            org.apache.axis2.extensions.spring.receivers.SpringServletContextObjectSupplier
    </parameter> 

    <!--SpringBeanName 是固定的不变的配置在applicationContext中配置的bean,,这里的值域bean中的id事一样的,否则就报错找不到bean错 -->

<parameter name="SpringBeanName">testService</parameter> <messageReceivers> <!-- 配置没有和有返回值的方法 一下两种最为常见--> <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out" class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" /> <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only" class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver" /> </messageReceivers> </service>


配置在applicationContext中配置的bean,,这里的值域bean中的id事一样的,否则就报错找不到bean错 -->

<parameter name="SpringBeanName">testService</parameter> <messageReceivers> 
<!-- 配置没有和有返回值的方法 一下两种最为常见--> 
     <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out" class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" /> 
     <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only" class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver" />
 </messageReceivers> </service>

 

 
<span style="color:#FF0000;"><strong>(3),web.xml配置文件</strong></span>

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 
	xmlns="http://java.sun.com/xml/ns/javaee" 
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
	http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
  <display-name></display-name>	
  
    <listener>
            <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <context-param>
       <param-name>contextConfigLocation</param-name>
       <param-value>classpath*:/applicationContext*.xml</param-value>
    </context-param>

  <!--axis2  WebService配置信息开始-->
   <servlet>
        <servlet-name>AxisServlet</servlet-name>
       <servlet-class>org.apache.axis2.transport.http.AxisServlet
       </servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>AxisServlet</servlet-name>
        <url-pattern>/services/*</url-pattern>
    </servlet-mapping>

</web-app>

<span style="color:#FF0000;"><strong>4,两个java文件中的代码</strong></span>

<pre name="code" class="html">InterfaceImpl.java


package com.wondersgroup.axis2.test;
public class InterfaceImpl implements TestServiceInface{
           public String getMessage(String message) {
           return message;
    }
}

TestServiceInface.java

package com.wondersgroup.axis2.test;
public interface TestServiceInface {
    public String getMessage(String message);}


 

 

3,当然最主要的就是相关的jar包了

下面是我整合的例子,有兴趣的可以下载

(1)spring3.2.5和axis2 1.6.2整合(1分)   http://download.csdn.net/detail/wd4871/9191725

(2)spring4.0.0和hibernate4.2和axis2 1.6.2整合(2分)   http://download.csdn.net/detail/wd4871/9191765


如果配置成功了可以通过  http://localhost:8080/webAxis2/services/LessonAction?wsdl 进行访问了





  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值