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;
}
}
//===================================================
<!-- https://mvnrepository.com/artifact/org.apache.cxf/cxf-rt-frontend-jaxws -->
<!-- https://mvnrepository.com/artifact/axis/axis -->
<dependency>
<groupId>axis</groupId>
<artifactId>axis</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>3.1.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.cxf/cxf-core -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-core</artifactId>
<version>3.1.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.cxf/cxf-rt-transports-http -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>3.1.6</version>
</dependency>