import javax.jws.WebService;
@WebService
public interface Web {
public List<Port> getPortList();
}
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
@Service
public class WebImpl implements Web {
// 获取港口数据库
@Override
public List<Port> getPortList() {
// TODO Auto-generated method stub
RestTemplate client=new RestTemplate();
String url="http://12.123.12.123:8080/abc/abcd";
String portString=client.getForObject(url, String.class);
JsonTools jsonTools = new JsonTools();
String className = "com.cn.eport.pojo.Port";
Class clazz = null;
try {
clazz = Class.forName(className);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
List<Port> portList=jsonTools.jsonToList(portString,clazz);
return portList;
}
}