java http调用接口书写?

要求写个接口连对面的提供的接口 对面返回的是一个list对象集合 目前环境是S2SH 怎么去书写呢?如果写好了 怎么在本机测试呢?求大神解答啊 有例子或什么写出来的最好了 感谢啊

1、直接用servlet就可以了,request.getInputStream(),然后解析xml,然后你的业务操作,组装XML,response.getOutputStream()写出去就OK了4但这个性能低,而且还要依赖web容器imq2、socket实现http协议,把HTTP协议好好看看,自己解析(其实就是字符串的操作哦)。3、你要是只做客户端的话可以用httpClient284几行代码搞定了
温馨提示:答案为网友推荐,仅供参考
第1个回答  推荐于2016-08-22

rest接口的话可以使用

RestTemplate

String uri = "http://example.com/hotels/1/bookings";

PostMethod post = new PostMethod(uri);
String request = // create booking request content
post.setRequestEntity(new StringRequestEntity(request));

httpClient.executeMethod(post);

if (HttpStatus.SC_CREATED == post.getStatusCode()) {
  Header location = post.getRequestHeader("Location");
  if (location != null) {
    System.out.println("Created new booking at :" + location.getValue());
  }
}

api文档参考http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/remoting.html#rest-client-access

本回答被提问者和网友采纳
第2个回答  2013-07-18
你说的我没怎么听懂。http://localhost:8080(tomcat端口号)/项目名称
相似回答