我有一个具有访问WCF服务的参数的url,该服务读取参数并执行执行返回JSON对象的搜索的方法:
{
"GetUsersByNameMethodResult":[
{
"City":"CONTAGEM",
"Id":11,
"Name":"Alice"
},
{
"City":"BELO HORIZONTE",
"Id":7,
"Name":"Marcia"
},
{
"City":"RIO DE JANEIRO",
"Id":9,
"Name":"Marcos"
},
]
}
这是我在Android中使用的代码:
// Making HTTP request
try {
// defaultHttpClient
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(url);
HttpResponse httpResponse = httpClient.execute(httpGet);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
但是在运行上述代码时发生错误时,任何人都知道如何解决这个问题?谢谢。