axis 和spring 集成

本文介绍了Axis与Spring的两种集成方法。一种是通过provider='java:SPRINGRPC'的配置,另一种是通过继承ServletEndpointSupport并利用Spring获取bean。集成的关键步骤包括在applicationContext-webservice.xml中配置bean,在server-config.wsdd中描述服务,并确保暴露的服务能够获取到Spring容器中的其他bean。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

 

axis 和spring 集成  有两种方式,关键点式axis 对外暴露的 业务类 和 spring 容器 为我们提供的bean 如何 相互

 

1. 网上有段代码 写了一个 provider="java:SPRINGRPC"   把他写的类导入到工程中,按照下面的方式即可集成成功

 

http://www.99inf.net/SoftwareDev/Java/23450.htm 

 

 

2. 如何吧一个普通的java类发布成webservice 比较简单,可以参考我的附件中的文档,就不说了,现在我们说下使用网上  方法如何集成 axis 和spring  的关键步骤

 

 a. 首先 建立 cn.com.xinli.axis.spring 包 ,将 集成代码全部拷贝进去

 b. 在 applicationContext-webservice.xml 中 配置 集成需要的bean

 

<?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: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-2.0.xsd
           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">

    <!-- axis 和spring 集成需要 -->
    <bean id="axissetup" class="cn.com.xinli.axis.spring.SpringAxisSetup">
    </bean>
    <!-- 对外暴露的 webservice 接口 -->
    <bean id="callWebService" class="cn.com.xinli.webservice.CallWebService">
    </bean>
    
    
	<!-- 银行缴费实现  -->
	 <bean id="payBank" class="cn.com.xinli.webservice.business.impl.PayBankRecive">	
	</bean>
	<!-- 客户服务实现  -->
	 <bean id="custService" class="cn.com.xinli.webservice.business.impl.CustService">
	 	<property name="dataSource" ref="dataSource"></property>
	</bean>
</beans>

 

 c. 在 server-config.wsdd 中增加 对外暴露的service 描述,重点注意 修改className为 springBeanClass,并且加上 springBean 描述

 

 

<service name="CallWebService" provider="java:SPRINGRPC">
  <operation name="service" qname="ns1:service" returnQName="serviceReturn" returnType="soapenc:string" soapAction="" xmlns:ns1="http://webservice.tdm.xinli.com.cn" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
   <parameter name="haader" type="soapenc:string"/>
   <parameter name="body" type="soapenc:string"/>
  </operation>
  <parameter name="allowedMethods" value="service"/>
  <parameter name="typeMappingVersion" value="1.2"/>
  <parameter name="wsdlPortType" value="CallWebService"/>
  <parameter name="wsdlServicePort" value="CallWebService"/>
  <parameter name="wsdlTargetNamespace" value="urn:CallWebService"/>
  <parameter name="springBeanClass" value="cn.com.xinli.webservice.CallWebService"/>
  <parameter name="springBean" value="callWebService"/>
 </service>

 

d.  我们对外暴露的是 callWebService 这个bean ,如果需要spring 的其他bean ,只需要在 xml中把其他的bean注入到callWebService 这个bean中 然后再 callWebService  这个bean 写上setter方法就OK了!

 

 

现在找到了一中超级简单的方法,axis 和spring 集成的关键在于 axis 对外暴露的方法中如何得到 spring 中的bean

,其实只需要 我们对外 暴漏的类 继承自 ServletEndpointSupport  然后使用

 

final ApplicationContext  applicationContext=getApplicationContext();
ServiceInterface serviceInterface=(ServiceInterface)applicationContext.getBean(head);

 

就可以得到bean 了

 

 

 

附件中是整个集成的 例子 和 一个快速发布的 文档(很久以前写的)

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值