Hello, I didn'y manage to query a web service from android emulator (previously I had a UnresolvedHostException but this is ok). Now that I can go any further, I do not have anything returned in the HttpResponse's Entity (length is -1).
String url = serverUrl + resource;
Log.d(TAG, "GET: " + url);
HttpClient client = new DefaultHttpClient();
HttpGet getMethod = new HttpGet((url));
getMethod.setHeader("User-Agent", USER_AGENT);
getMethod.addHeader("Authorization", "Basic " + getCredentials());
HttpResponse httpResponse = client.execute(getMethod);
Log.e(TAG, "RESPONSE:" + httpResponse);
Log.i(TAG,httpResponse.getStatusLine().toString());
Log.i(TAG + "1",httpResponse.getLocale().toString());
Log.i(TAG + "2",httpResponse.getHeaders(USER_AGENT).toString());
Log.i(TAG + "3",httpResponse.getEntity().toString());
Log.i(TAG + "4",httpResponse.getEntity().getContent().toString());
int length = (int) httpResponse.getEntity().getContentLength();
Log.e(TAG + "5", "LENGTH:" + length);
The logs:
D/HttpServices( 275): GET: http://www.google.com/search?q=android
D/dalvikvm( 275): GC freed 2992 objects / 217016 bytes in 103ms
E/HttpServices( 275): RESPONSE:org.apache.http.message.BasicHttpResponse@43ca4920
I/HttpServices( 275): HTTP/1.1 200 OK
I/HttpServices1( 275): en_US
I/HttpServices2( 275): [Lorg.apache.http.Header;@43c44e10
I/HttpServices3( 275): org.apache.http.conn.BasicManagedEntity@43c40be8
I/HttpServices4( 275): org.apache.http.conn.EofSensorInputStream@43c51c60
E/HttpServices5( 275): LENGTH:-1
I'm not behind a proxy and have added the INTERNET permission in the manifest. What can be the reason for not retrieving the content of the get query (http://www.google.com/search?q=android). Thanks a lot for your help, Luc