+-
                                
                                    
                                
                                
                                    
                                
                                
                                    
                                        
                                        
                                        
                                        
                                        服务器端:
1、建立一个新的项目springXfireWebService (客户端)
2、在官网http://xfire.codehaus.org/Download中下载:xfire-distribution-1.2.6.zip (在建立项目后将所有jar包放到lib包中,测试删掉几个发现不行,似乎都是需要的,忘高手指明不足)和xfire-all-1.2.6.jar 。
6、与spring整合spring-context.xml:
客户端:
1、建立新的项目springXfireClient(客户端)
2、建立service:
Hello
完成。注意这里没有涉及到与数据库的交互,可以在实现中完善,另外在在spirng中配置。
                                            
                                        
                                        
                                    
                                
                            
                        
1、建立一个新的项目springXfireWebService (客户端)
2、在官网http://xfire.codehaus.org/Download中下载:xfire-distribution-1.2.6.zip (在建立项目后将所有jar包放到lib包中,测试删掉几个发现不行,似乎都是需要的,忘高手指明不足)和xfire-all-1.2.6.jar 。
3、建立webService:
package com.ebiz.xfire.service;
import java.util.List;
import com.ebiz.xfire.domain.CscProject;
/**
 * @author Ethan,Woo
 */
public interface CscWebService {
	/**
	 *@author Ethan,Woo
	 *@desc "加载项目库数据"
	 *@date 2009-09-28
	 */
	List<CscProject> getCscProjectList(CscProject t);
	
}
4、实现:
package com.ebiz.xfire.service.impl;
import com.ebiz.xfire.service.WyWebService;
/**
 * @author Ethan,Woo
 */
public class WyWebServiceImpl implements WyWebService {
	public void printHello() {
		System.out.println("Hello!");
	}
}
	
6、与spring整合spring-context.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:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:jee="http://www.springframework.org/schema/jee" 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.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd" default-autowire="byName"> <import resource="classpath:org/codehaus/xfire/spring/xfire.xml" /> <!-- ====================testSpringXfire================= --> <bean id="wyWebServiceImpl" class="com.ebiz.xfire.service.impl.WyWebServiceImpl" /> <bean id="addressingHandler" class="org.codehaus.xfire.addressing.AddressingInHandler" /> <bean name="webService" class="org.codehaus.xfire.spring.ServiceBean"> <property name="serviceBean" ref="wyWebServiceImpl"></property> <property name="serviceClass" value="com.ebiz.xfire.service.WyWebService"></property> <property name="inHandlers"> <list> <ref bean="addressingHandler" /> </list> </property> </bean> </beans>
	
	
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
	<display-name>XFireTest</display-name>
	<welcome-file-list>
		<welcome-file>index.html</welcome-file>
		<welcome-file>index.jsp</welcome-file>
	</welcome-file-list>
  <context-param> 
    <param-name>contextConfigLocation</param-name> 
    <param-value>classpath:spring-context.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.spring.XFireSpringServlet</servlet-class> 
  </servlet> 
  <servlet-mapping> 
    <servlet-name>XFireServlet</servlet-name> 
    <url-pattern>/servlet/XFireServlet/*</url-pattern> 
  </servlet-mapping> 
  <servlet-mapping> 
    <servlet-name>XFireServlet</servlet-name> 
    <url-pattern>/services/*</url-pattern> 
  </servlet-mapping> 
</web-app>
	
客户端:
1、建立新的项目springXfireClient(客户端)
2、建立service:
	
package com.ebiz.xfire.service;
/**
 * @author Ethan,woo
 * @version 2009-09-28
 */
public interface WyWebService {
	/**
	 *@desc "打印Hello"
	 */
	 void printHello();
}
注意:这里的包的目录结构一定要和客户端的包的结构一定要一样(本人吃过亏的~~~~(>_<)~~~~ )
3、建立test.java
package com.testxfire.client;
import java.net.MalformedURLException;
import org.codehaus.xfire.XFireFactory;
import org.codehaus.xfire.client.XFireProxyFactory;
import org.codehaus.xfire.service.Service;
import org.codehaus.xfire.service.binding.ObjectServiceFactory;
import com.ebiz.xfire.service.WyWebService;
public class Test {
	public static void main(String[] args) {
		Service serviceModel = new ObjectServiceFactory().create(WyWebService.class);
		XFireProxyFactory factory = new XFireProxyFactory(XFireFactory.newInstance().getXFire());
		String url = "http://localhost:8080/springXfireWebService/services/WyWebService";
		try {
			WyWebService cws = (WyWebService) factory.create(serviceModel, url);
			cws.printHello();
		} catch (MalformedURLException e) {
			e.printStackTrace();
		}
	}
}
	
Hello
完成。注意这里没有涉及到与数据库的交互,可以在实现中完善,另外在在spirng中配置。