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
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:applicationContext-*.xml,classpath:org/codehaus/xfire/spring/xfire.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>xfireServlet</servlet-name>
<servlet-class>org.codehaus.xfire.transport.http.XFireConfigurableServlet</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>xfireServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>XFireServlet</servlet-name>
<servlet-class>
org.codehaus.xfire.spring.XFireSpringServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>XFireServlet</servlet-name>
<url-pattern>/servlet/XFireServlet/*</url-pattern>
</servlet-mapping>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>login.jsp</welcome-file>
</welcome-file-list>
</web-app>
《4》配置struts.xml(在该例子中还用不到它,以下配置只是与spring2集成)
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.objectFactory" value="spring" />
<package name="public" extends="struts-default">
<action name="login" class="loginAction">
......
</action>
</package>
</struts>
《5》配置applicationContext-beans.xml
<?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="connectDb" class="jxust.zjh.db.ConnectDb" />
<bean id="educate" class="jxust.zjh.educateImpl" />
<bean name="helloService" class="org.codehaus.xfire.spring.ServiceBean">
<property name="serviceBean" ref="educate"/>
<property name="serviceClass" value="jxust.zjh.Ieducate"/>
<property name="inHandlers" ref="addressingHandler" />
</bean>
<bean id="addressingHandler" class="org.codehaus.xfire.addressing.AddressingInHandler"/>
</beans>
《6》配置applicationContext-actions.xml
<?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="public" abstract="true">
<property name="connectDb" ref="connectDb" />
</bean>
<bean id="loginAction" class="jxust.zjh.actions.LoginAction" scope="prototype" parent="public">
</bean>
</beans>
《7》修改services.xml(由于用的是spring2.0,所以把xmlns="http://xfire.codehaus.org/config/1.0"放在<service>中)
<?xml version="1.0" encoding="UTF-8"?>
<beans >
<service xmlns="http://xfire.codehaus.org/config/1.0">
<name>educate</name>
<serviceClass>jxust.zjh.Ieducate</serviceClass>
<implementationClass>jxust.zjh.educateImpl</implementationClass>
<style>wrapped</style>
<use>literal</use>
<scope>application</scope>
</service></beans>
《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整合结束!
分享到:
相关推荐
用XFire开发WebService Spring注解
spring+xfire( 编写webservice完整配置+案例)
xfire实现webservice实例,XFire WebService开发快速起步
自己写给同事培训的xfire整合spring的小项目 步骤清晰 简单易懂 适合刚刚接触xfire的同事们
xfire开发webservice以及Android利用ksoap2访问webservice。包括源码和jar包
webservice xfire整合spring(webservice配置采用注解),demo包含xfire 与spring整合的配置,客户端和服务端的代码,及jar包
Spring+xFire实现webService
MyEclipse下XFire开发Webservice实例.doc 基于XFire开发Webservice实例。
提供xfire开发webservice接口的详细说明文档;同时给出通过xfire框架开发webservice服务端依赖的jar包。非常适合新手入门~
spring3.0整合Xfire1.2.6 开发webservice需要的jar包
xfire-spring-1.2.2.jar xfire-xmlbeans-1.2.2.jar 支持将Web服务绑定到POJO、XMLBeans、JAXB1.1、JAXB2.0和Castor; 支持基于HTTP、JMS、XMPP等多种协议访问Web服务; 支持多种Web服务业界重要标准如SOAP、WSDL、...
多的不说,就是xfire构建WebService例子,分为服务端和客户端
此程序demo详细描述的从发布接口到调用接口的全部过程,详细描述了Xfire调用webservice参数无法传递的问题。
在MyEclipse中使用XFire开发WebService WebService开发
xfire开发webservice与调用 用起来比axis简单,容易上手。没有axis那么复杂。性能也比axis好。附件里面包含教程文档及实例代码
xfire webservice 集成spring客户端封装成到一个类打包到客户端就像调静态方法一样
java使用XFire调用webService接口
使用xfire开发webservice的客户端需要的完整jar包,直接导入开放就可以用了。使用Xfire构建JAVA的webService全过程(从服务端到客户端)
xfire+spring开发webservice 很不错的文档
xfire开发webservice文档.pdf