【文件属性】:
文件名称:XFire 和spring完整集成实例
文件大小:68KB
文件格式:RAR
更新时间:2015-03-27 08:12:44
XFire 和spring完整集成实例
package com.xfire.core.client;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.codehaus.xfire.client.XFireProxyFactory;
import org.codehaus.xfire.service.Service;
import org.codehaus.xfire.service.binding.ObjectServiceFactory;
import com.xfire.core.entity.UserInfo;
import com.xfire.core.service.IUserInfoService;
/**
*@author jilongliang
*@Date 2012-3-5
*
*/
public class UserInfoClient {
public static void main(String[] args) {
getServiceList();
setServiceList();
}
static String url = "http://localhost:8081/xfire/services/UserInfo";
/**
*
*/
public static void getServiceList() {
Service service = new ObjectServiceFactory()
.create(IUserInfoService.class);
try {
IUserInfoService iAddressService = (IUserInfoService) new XFireProxyFactory()
.create(service, url);
List list = (ArrayList) iAddressService
.getAddressList();
System.out.println("一共多少条数据:" + list.size());
for (Iterator iter = list.iterator(); iter.hasNext();) {
UserInfo a = iter.next();
System.out.println(a);
}
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
public static void setServiceList() {
Service service = new ObjectServiceFactory()
.create(IUserInfoService.class);
try {
IUserInfoService iAddressService = (IUserInfoService) new XFireProxyFactory()
.create(service, url);
List listAdd = new ArrayList();
UserInfo address = new UserInfo();
address.setIdentifier(1);
address.setCountry("中國");
address.setProivice("廣東省");
address.setCity("陽江");
address.setAddress("廣東陽春");
address.setPostCode("1111111");
address.setExist(false);
address.setArrary(new String[] { "22", "23", "24" });
listAdd.add(address);
address.setIdentifier(2);
address.setCountry("中國");
address.setProivice("廣東省");
address.setCity("陽江");
address.setAddress("廣東陽春");
address.setPostCode("1111111");
address.setExist(false);
address.setArrary(new String[] { "a", "b", "c" });
listAdd.add(address);
List returnAdd = iAddressService.setAddresses(listAdd);
System.out.println("总数:" + returnAdd);
for (Iterator it = returnAdd.iterator(); it.hasNext();) {
UserInfo address2 = it.next();
System.out.println(address2);
}
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
}