use wsf/spring integration axis2 with spring

以前一直以为axis2和spring的结合不是像xfire(代码优先策略)那样方便
现在wsf/spring项目使得用axis2可以像xfire一样简单的进行ws暴露。

具体步骤

1)首先需要JDK5,axis2的众 包和wsf-spring-*.jar

2)书写web.xml

<?xml version=”1.0″ encoding=”ISO-8859-1″?>
<!DOCTYPE web-app PUBLIC “-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN” “http://java.sun.com/dtd/web-app_2_3.dtd”>

<web-app>

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<servlet>
<servlet-name>axis2</servlet-name>
<servlet-class>org.wso2.spring.ws.servlet.SpringAxis2Servlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>axis2</servlet-name>
<url-pattern>/axis2/*</url-pattern>
</servlet-mapping>
</web-app>

3)axis2Config.xml 使用wsf项目默认的,不用动除非你知道怎么用

4)书写你的业务接口和业务实现,都是基于pojo的

5)配置applicationContext.xml,并暴露你的ws接口

<?xml version=”1.0″ encoding=”UTF-8″?>
<beans xmlns=”http://www.springframework.org/schema/beans”
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xsi:schemaLocation=”http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd”>

<import resource=”axis2Config.xml”/>

<!– Sample Service –>

<bean id=”services” class=”org.wso2.spring.ws.WebServices”>
<property name=”services”>
<list>
<bean id=”productManService” class=”org.wso2.spring.ws.SpringWebService”>
<property name=”serviceBean” ref=”productManager”></property>
<property name=”serviceName” value=”TestProductManager”></property>
<property name=”serviceDescription” value=”This is the test webservice for Spring/Axis2 Integration” ></property>
<property name=”targetNameSpace” value=”www.springtest.com”></property>
<property name=”excludeOperations”>
<list>
<bean id=”test” class=”org.wso2.spring.ws.beans.OperationBean”>
<property name=”name” value=”increasePrice”></property>
</bean>
</list>
</property>
<property name=”sessionScope” value=”request”></property>
<property name=”modules”>
<list>
<value>addressing</value>
</list>
</property>
</bean>
</list>
</property>
</bean>

<bean id=”productManager” class=”com.hello.sample.service.SimpleProductManager”/>

</beans>

ws
http://xfire.codehaus.org
http://ws.apache.org/axis
第2代ws
http://ws.apache.org/axis2
http://cxf.apache.org
http://www.springframework.org/spring-ws 契约优先开发ws

原创文章,转载请注明: 转载自海波无痕

本文链接地址: use wsf/spring integration axis2 with spring

文章的脚注信息由WordPress的wp-posturl插件自动生成

此条目发表在javaee分类目录,贴了, , , , 标签。将固定链接加入收藏夹。

发表评论

电子邮件地址不会被公开。 必填项已用*标注

评论链接可以 移除 nofollow.