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">
-
-
-
<
bean
id
=
"axissetup"
class
=
"cn.com.xinli.axis.spring.SpringAxisSetup"
>
-
</
bean
>
-
-
<
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
>
<?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
>
<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);
final ApplicationContext applicationContext=getApplicationContext();
ServiceInterface serviceInterface=(ServiceInterface)applicationContext.getBean(head);
就可以得到bean 了
附件中是整个集成的 例子 和 一个快速发布的 文档(很久以前写的)
分享到:
相关推荐
axis2与spring的集成,在application中配置要发布的Java类,然后配置aar文件,在aar打包文件中的services.xml要嵌入 <parameter name="ServiceObjectSupplier">org.apache.axis2.extensions.spring.receivers....
spring集成axis发布webservice源码 spring集成axis发布webservice源码 spring集成axis发布webservice源码 spring集成axis发布webservice源码
将 Spring 集成 AXIS2 可以实现基于 Spring 的 Web 服务配置,该配置方法可以提高开发效率和系统可维护性。 一、配置 Spring 项目 首先,需要在 Spring 项目中添加 AXIS2 的依赖项,包括 axis2-spring-1.4.1.jar ...
axis1.4 spring3.0 集成 实现 web service 服务端, axis1.4 客户端认证,授权,访问日志记录,集成spring 解决 PHP 调用web service 无法认证,和解析soap 模板
Axis2集成Spring发布WebServices服务
springboot集成axis2-1.7.9部署和调用实例
spring+axis集成webservice
本示例是在 Axis2 通过 外部 Spring容器 获取指定的实现Bean,以提供服务。全部自己写WSDL和服务实现类,不使用 Axis2提供的 Java2WSDL 和 WSDL2Java 工具
Spring集成axis2实现webservice所用到的Jar包,将所有的包放到项目的LIB目录下面
使用axis2与spring3进行集成,实现的webservice服务。 资料为myeclipse下的web工程,可解压后直接导入。 发布到tomcat6下运行。
相对于Axis来说,目前XFire相对受欢迎,加上其提供了和Spring集成的支持,在目前的Web Service开源社区拥有众多的追随者。并且因为XFire为Spring提供的支持,使得我们可以很容易在Spring中使用XFire构建Web Service...
Spring boot 集成Axis1.4 ,使用wsdd文件发布webservice
axis2+spring+ibatis整合的一个项目,含webservice文件传输
NULL 博文链接:https://wujianjun.iteye.com/blog/517152
通过axis2与spring进行集成,发布webservice服务,
本文是关于webservcie开发指南,其中主要包括:基本概念、使用axis来进行开发和测试、axis和spring集成开发、aixs和web服务期集成开发、通过ObjectWeb Lomboz工具生成客户端和服务器代码方式等等。 核心内容包括: ...
包含集成文档,所需jar包,测试类,已用于实际项目开发
实现Springcloud向dubbo项目的接口调用。 FeignToDubbo-starter模块负责利用Feign将底层的Http协议转化为dubbo协议,供SpringCloud项目使用。引入FeignToDubbo-starter后会引入dubbo的依赖,使用注解DubboRefence...
springboot 集成axis1.4的webservice,该为maven的工程