我有一个 url,它有一个参数来访问 WCF 服务,该服务读取参数并执行一个方法,该方法执行返回 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();
}
但是每当运行上述代码时出现错误,有人知道如何解决这个问题吗?谢谢你。