公司之前的外部接口都是soap协议的,通过wsdl文件生成客户端代码,客户端通过发请求到中间环节(暂且这样称),中间环节根据地址和接口名映射到外部接口,返回数据,但是现在新的接口是jersery框架,没有wsdl文件,调用方法也和之前的不同,现在不清楚怎么能把请求发到中间环节,再通过其查询外部接口获得数据,
关键项目不能直接连外部接口,必须通过中间才能调用外部接口,请教下,有没有什么方案,谢谢大家了,
jersery接口是通过URL地址创建的资源,查询返回结果,不清楚怎么通过client把请求发送到中间环节,再通过中间环节查询外部接口获得数据,有想法的麻烦帮下忙,谢谢了
public class ContactClient {
public static void main(String[] args) {
Client c = Client.create();
WebResource r = c.resource("http://localhost:8080/RestService/rest/contacts");
System.out.println("===== Get huangyim =====");
getOneContact(r, "huangyim");
}
public static void getOneContact(WebResource r, String id) {
GenericType<JAXBElement<Contact>> generic = new GenericType<JAXBElement<Contact>>() {};
JAXBElement<Contact> jaxbContact = r.path(id).accept(MediaType.APPLICATION_XML).get(generic);
Contact contact = jaxbContact.getValue();
System.out.println(contact.getId() + ": " + contact.getName());
}
}