package com.oa.test;
import java.net.URL;
import org.codehaus.xfire.client.Client;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
/**
* @author 作者:Iwen
* @version 创建时间:2017年12月13日 上午11:38:57
* @ClassName 类名称
* @Description 类描述
*/
public class TmpTest {
public static void main(String[] args) {
try {
Client client = new Client(new URL("http://localhost:8080/z_land_webservice/service/IGetInfo?wsdl"));
Object[] res = client.invoke("getElecRoomByProjectId", new Object[]{"7fTQLojc"});
JSONObject jsonObject = JSONArray.fromObject(res).getJSONObject(0);
//invoke方法有两个参数,一个是接口的方法名,一个是接口方法的参数列表
System.out.println(jsonObject);
} catch (Exception e) {
e.printStackTrace();
System.out.println(e);
}
}
}
还有一个需要注意的就是得加一个包到运行库,虽然这里没有引那个包,但是如果不把那个包加运行库,运行是通不过的。就是XmlSchema-1.4.6.jar,下载地址:http://download.csdn.net/download/genius_wolf/10165603