XFire 1.2.6
从官方网 上下载xfire-distribution-1.2.6.zip,下载到本地解压后可以得到XFire编译打包后的文件xfire-all-1.2.6.jar,lib目录下为XFire所依赖的第三方Jar文件,在开发的时候用得到,此外还包括手册和几个例子。建议在Eclipse里建一个用户库,把 xfire-all-1.2.6.jar和XFire所依赖的第三方Jar文件都包含进去。
建立一个Tomcat工程,名叫XFireSpring。--用里面spring的例子
WEB-INF文件夹下web.xml :
<?xml version="1.0" encoding="UTF-8"?> <!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> <!-- START SNIPPET: xfire --> <!--xfire使用 classpath:org/codehaus/xfire/spring/xfire.xml--> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/applicationContext.xml</param-value> <!--classpath:org/codehaus/xfire/spring/xfire.xml --> </context-param> <context-param> <param-name>log4jConfigLocation</param-name> <param-value>/WEB-INF/log4j.properties</param-value> </context-param> <listener> <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class> </listener> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!-- 配合Spring容器中XFire一起工作的Servlet--> <servlet> <servlet-name>xfire</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>xfire</servlet-name> <url-pattern>/services/*</url-pattern><!-- 在这个URI下开放Web Service服务 --> </servlet-mapping> <!-- END SNIPPET: xfire --> </web-app>
WEB-INF文件夹下xfire-servlet.xml :
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <!-- 引入XFire预配置信息 --> <import resource="classpath:org/codehaus/xfire/spring/xfire.xml"/> <!-- START SNIPPET: xfire --> <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> <property name="urlMap"> <map> <entry key="/EchoService"><!-- 访问路径http://127.0.0.1:8080/XFireSpring/services/EchoService?wsdl --> <ref bean="echo"/> </entry> </map> </property> </bean> <!-- Declare a parent bean with all properties common to both services --> <bean id="echo" class="org.codehaus.xfire.spring.remoting.XFireExporter"> <!-- 引用xfire.xml中定义的工厂 --> <property name="serviceFactory"> <ref bean="xfire.serviceFactory"/> </property> <!-- 引用xfire.xml中的xfire实例 --> <property name="xfire"> <ref bean="xfire"/> </property> <property name="serviceBean"> <ref bean="echoBean"/> </property> <property name="serviceClass"> <value>org.codehaus.xfire.spring.example.Echo</value> </property> </bean> <bean id="echoBean" class="org.codehaus.xfire.spring.example.EchoImpl"/> <!-- END SNIPPET: xfire --> </beans>
具体详看附件 。
http://127.0.0.1:8080/ XFireSpring/services/EchoService?wsdl