xfire----客户端

第一步:定义接口
public interface UnionDataQuery {
    String[][] getQueryData(String params);
}

第二部:实现几口:
public class ReportDataClient {
	private static String serviceURL = PropUtil.getProp(Const.WEBSERVICE_DADA_URL);//远程地址如:http://192.168.0.219/cnservice/services/UnionDataQuery
	private static Logger logger=Logger.getLogger(ReportDataClient.class);
	
	public static String[][] getQueryData(String params) {
		String[][] datas = null;		
		// 创建service对象
		Service serviceModel = new ObjectServiceFactory().create(
				UnionDataQuery.class, null, "", null);

		XFireProxyFactory serviceFactory = new XFireProxyFactory();
		try {
			// 获取服务对象
			UnionDataQuery service = (UnionDataQuery) serviceFactory.create(
					serviceModel, serviceURL);

			// 获取客户端代理
			Client client = ((XFireProxy) Proxy.getInvocationHandler(service))
					.getClient();

			// 同时启动response和request压缩
			client.setProperty(CommonsHttpMessageSender.GZIP_ENABLED,
					Boolean.TRUE);
			// 忽略超时
			client.setProperty(CommonsHttpMessageSender.HTTP_TIMEOUT, "0");

			// 调用服务
			datas = service.getQueryBySids(startDate, endDate, stses, sids);
		} catch (Exception e) {
			logger.error("getQueryDatais error:", e);
		}
		
		
		return datas;
	}

你可能感兴趣的:(java,webservice)