ฉันกำลังพยายามเรียกใช้บริการเว็บ RESTful จากแอปพลิเคชัน Android โดยใช้วิธีการต่อไปนี้:
HttpHost target = new HttpHost("http://" + ServiceWrapper.SERVER_HOST,ServiceWrapper.SERVER_PORT);
HttpGet get = new HttpGet("/list");
String result = null;
HttpEntity entity = null;
HttpClient client = new DefaultHttpClient();
try {
HttpResponse response = client.execute(target, get);
entity = response.getEntity();
result = EntityUtils.toString(entity);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (entity!=null)
try {
entity.consumeContent();
} catch (IOException e) {}
}
return result;
ฉันสามารถเรียกดูที่อยู่และดูผลลัพธ์ xml โดยใช้เบราว์เซอร์ Android Emulator และจากเครื่องของฉัน ฉันให้สิทธิ์อินเทอร์เน็ตแก่แอปของฉันแล้ว
ฉันกำลังพัฒนาด้วย eclipse
ฉันเคยเห็นมันบอกว่าฉันอาจจำเป็นต้องกำหนดค่าพรอกซี แต่เนื่องจากบริการเว็บที่ฉันโทรอยู่บนพอร์ต 80 สิ่งนี้จึงไม่ควรสำคัญใช่ไหม ฉันสามารถเรียกวิธีการด้วยเบราว์เซอร์ได้
มีความคิดอะไรบ้าง?