I have a friend who's written a servlet which just serves XML (just XML, no SOAP or etc., Content-Type: text/xml).
Now I'm trying to access it using android. I can access the page fine if I surf to the page with firefox, but if I access it using my android application I get an HTTP 502 error.
The code I'm using is:
AlertDialog alertDialog;
HttpClient httpClient = new DefaultHttpClient();
HttpContext localContext = new BasicHttpContext();
HttpGet httpGet = new HttpGet("x");
try {
HttpResponse response = httpClient.execute(httpGet, localContext);
alertDialog = new AlertDialog.Builder(view.getContext()).create();
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
return;
}
});
alertDialog.setTitle("Response");
alertDialog.setMessage(response.getStatusLine().toString());
alertDialog.show();
alertDialog.setMessage(EntityUtils.toString(response.getEntity()));
alertDialog.show();
} catch (IOException e) {
alertDialog = new AlertDialog.Builder(view.getContext()).create();
alertDialog.setTitle("Sorry");
alertDialog.setMessage("There was a problem connecting to the login-service.");
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
return;
}
});
alertDialog.show();
}
And are there any recommended ways to parse the XML? Like if there was a specific tag in there such as title, message, ...