axis2系列之与spring集成
来源:互联网 发布:查找两列不同数据 编辑:程序博客网 时间:2024/04/25 20:40
Spring与Axis2集成注意事项以及步骤:
- spring使用配置文件进行实体bean的注入方式不变,applicationContext.xml文件内容也不变只是需要将applicationContext.xml文件放在WEB-INF下。
- 在web.xml文件中加入spring的监听器,以及applicationcontext.xml配置文件的读取。
- 在spring配置文件中加入:<bean id="applicationContext" class="org.apache.axis2.extensions.spring.receivers.ApplicationContextHolder" />
- 重点:在WEB-INF/services文件下创建任一文件夹(名字随便,但必须创建),在该新创建的文件夹下创建一个文件夹名为META-INF文件夹,在META-INF文件夹下创建services.xml文件。
- 配置services.xml,在配置该文件中需要注意三个parameter的配置:
(1)、ServiceObjectSupplier的配置,固定值:org.apache.axis2.extensions.spring.receivers.SpringServletContextObjectSupplier
在 services.xml 文件中需要通过 ServiceObjectSupplier 参数指定 SpringServletContextObjectSupplier
类来获得 Spring 的 ApplicationContext 对象
类来获得 Spring 的 ApplicationContext 对象
(2)、SpringBeanName的配置:applicationContext.xml中指定bean的id。
服务器端:
public interface IWeatherService {void setWeather(Weather w);Weather getWeather();}
public class WeatherService implements IWeatherService {Weather weather;public void setWeather(Weather w) {weather = w;}public Weather getWeather() {return weather;}}
services.xml文件
<service name="springService"><description>springService</description><parameter name="ServiceObjectSupplier">org.apache.axis2.extensions.spring.receivers.SpringServletContextObjectSupplier</parameter><parameter name="SpringBeanName">weatherService</parameter><messageReceivers><messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" /></messageReceivers></service>applicationContext.xml文件
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"><beans><bean id="applicationContext" class="org.apache.axis2.extensions.spring.receivers.ApplicationContextHolder" /> <bean id="weatherService" class="com.test.springservice.impl.WeatherService"> <property name="weather"> <bean class="com.test.bean.Weather"> <property name="temperature" value="89.9" /> <property name="forecast" value="Sunny" /> <property name="rain" value="false" /> <property name="howMuchRain" value="0.2" /> </bean> </property> </bean></beans>客户端:
public static void main(String[] args1) throws AxisFault {EndpointReference targetEPR = new EndpointReference("http://localhost:8080/springAxis2project/services/springService");RPCServiceClient serviceClient = new RPCServiceClient();Options options = serviceClient.getOptions();options.setTo(targetEPR);QName opGetWeather = new QName("http://impl.springservice.test.com","getWeather");Object[] opGetWeatherArgs = new Object[] {};Class[] returnTypes = new Class[] { Weather.class };Object[] response = serviceClient.invokeBlocking(opGetWeather,opGetWeatherArgs, returnTypes);Weather result = (Weather) response[0];if (result == null) {System.out.println("Weather didn't initialize!");} else {System.out.println();System.out.println("Temperature : "+ result.getTemperature());System.out.println("Forecast : "+ result.getForecast());System.out.println("Rain : "+ result.getRain());System.out.println("How much rain (in inches) : "+ result.getHowMuchRain());}}
0 0
- axis2系列之与spring集成
- WebService之Axis2系列教程Axis2与Spring集成发布
- WebService之Axis2系列教程(八)Axis2与Spring集成发布
- WebService之Axis2系列教程(九)Axis2与Spring集成传递对象
- Axis2与Spring集成开发
- Axis2与Spring的集成
- Axis2与Spring集成发布
- Axis2与Spring集成发布
- Axis2与Spring集成发布
- Spring系列之与Struts的集成
- myeclipse+axis2+spring集成
- axis2.1.6+spring集成
- Axis2集成 spring
- axis2+spring集成
- MyBitis(iBitis)系列随笔之六:mybitis与spring集成
- MyBitis(iBitis)系列随笔之六:mybitis与spring集成
- Redis 讲解系列之 与Spring集成(一)
- Redis 讲解系列之 与Spring集成(二)
- linux alias 编写 函数 脚本
- 结构体在内存中的对齐方式
- 【Android】Android开发之自定义View的功能实现详解。教你一步一步学会自定义View
- C#获取当前项目路径
- 给 Android 开发者的 RxJava 详解
- axis2系列之与spring集成
- 星座配对中有哪些情侣是在吵吵闹闹中不断升温呢
- 内核读写锁
- TCP/UDP 报最大长度
- ScrollView嵌套ListView导致ListView只显示一行
- 利用curl模拟 移动端 接入 spring cloud security OAuth2
- 手把手教你在Windows环境下升级R
- 数据结构-队列
- java使用原生jdbc链接链接oracle数据库