xfire开发webservice整合spring struts2

xfire开发webservice整合spring struts2配置步骤:
《1》、导包
struts2:
1. commons-logging-1.0.4.jar
2. freemarker-2.3.13.jar
3. ognl-2.6.11.jar
4. struts2-core-2.1.6.jar
5. xwork-2.1.2.jar
6. commons-fileupload-1.2.1.jar
7. commons-io-1.3.2.jar
8. struts2-spring-plugin-2.1.6.jar

spring2:
1. log4j-1.2.14.jar
2. aspectjweaver.jar
3. aspectjrt.jar
4. spring.jar

xfire-1.2.6(从网上下载新版本,然后把jar包导入WEB-INF\lib下:xfire-all-1.2.6.jar和lib下的所有包)

《2》、删除一些会冲突的包
把lib下的x-fire中的spring-1.2.6.jar删掉,它会和spring2中的spring.jar包发生冲突。

《3》配置web.xnl

xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">


contextConfigLocation
classpath*:applicationContext-*.xml,classpath:org/codehaus/xfire/spring/xfire.xml


org.springframework.web.context.ContextLoaderListener



xfireServlet
org.codehaus.xfire.transport.http.XFireConfigurableServlet
0


xfireServlet
/services/*



XFireServlet

   org.codehaus.xfire.spring.XFireSpringServlet
 



  XFireServlet
/servlet/XFireServlet/*


struts2
org.apache.struts2.dispatcher.FilterDispatcher


struts2
*.jsp


struts2
*.action


login.jsp



《4》配置struts.xml(在该例子中还用不到它,以下配置只是与spring2集成)

"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">




......





《5》配置applicationContext-beans.xml

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">











《6》配置applicationContext-actions.xml

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">







《7》修改services.xml(由于用的是spring2.0,所以把xmlns="http://xfire.codehaus.org/config/1.0"放在中)



educate
jxust.zjh.Ieducate
jxust.zjh.educateImpl

literal
application


《8》编写一个简单的接口和实现类(用来测试)
Ieducate.java
package jxust.zjh;
public interface Ieducate {
public String queryStudent(String s_card);
}

EducateImpl.java(该实现类依赖了其他类的对象)
package jxust.zjh;
public class EducateImpl implements Ieducate {
public String queryStudent(String s_card) {
return "该学生学号是:"+s_card;
}
}

这样在浏览器中输入:http://localhost:8080/EducateSystem_server/services/educate?wsdl
就可以看到生成的wsdl文件了
xfire开发webservice整合spring struts2整合结束!

你可能感兴趣的:(webservices)