我开发了一个 android 应用程序,以收集保存在 Web API 上的订单。我使用 http 协议进行我的 Rest 调用,如下所示:
HttpClient httpClient = new DefaultHttpClient();
try {
HttpGet httpGet = new HttpGet("http://.../api/orders...");
HttpResponse httpResponse = httpClient.execute(httpGet);
HttpEntity httpEntity = httpResponse.getEntity();
if (httpEntity != null) {
InputStream inputeStream = httpEntity.getContent();
BufferedReader bufferReader = new BufferedReader(
new InputStreamReader(inputeStream));
StringBuilder stringBuilder = new StringBuilder();
String ligneLue = bufferReader.readLine();
while (ligneLue != null) {
stringBuilder.append(ligneLue + "\n");
ligneLue = bufferReader.readLine();
}
bufferReader.close();
SONObject jsonObject = new JSONObject(stringBuilder.toString());
...
...
(I collect what I need.)
...
...
}
现在我想使用Framework restlet 来做同样的想法。这是可能的?