I am trying to consume a the webservice below
http://62.253.195.179/disaster/webservices/login.php?message=[{"email":"
[email protected]","password":"welcome"}]
This returns a JSON array
[{"companyuserId":"2","name":"ben stein","superiorname":"Leon","departmentId":"26","departmentname":"Development","companyId":"23","UDID":"12345","isActive":"1","devicetoken":"12345","email":"
[email protected]","phone":"5456465465654","
userrole":"1","chngpwdStatus":"1"}]
My code is below
try{
String weblink = URLEncoder.encode("http://62.253.195.179/disaster/webservices/login.php?message=[{\"email\":\"
[email protected]\",\"password\":\"welcome\"}]");
HttpParams httpParameters = new BasicHttpParams();
int timeoutConnection = 7500;
HttpConnectionParams.setConnectionTimeout(httpParameters,
timeoutConnection);
int timeoutSocket = 7500;
HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket);
HttpClient client = new DefaultHttpClient(httpParameters);
HttpGet request = new HttpGet();
URI link = new URI(weblink);
request.setURI(link);
HttpResponse response = client.execute(request);
BufferedReader rd = new BufferedReader(new InputStreamReader(
response.getEntity().getContent()));
result = rd.readLine();
JSONObject myData = new JSONObject(result);
JSONArray jArray = myData.getJSONArray("");
JSONObject steps = jArray.getJSONObject(0);
String name = steps.getString("name");
} catch (JSONException e) {
e.printStackTrace();
}
But its not working and I am not 100% sure this is the best way to do it.
11-10 10:49:55.489: E/AndroidRuntime(392): java.lang.IllegalStateException: Target host must not be null, or set in parameters.