HttpPost httpRequest=new HttpPost(httpUrl);
List<NameValuePair> params=new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("ID","aa"));
params.add(new BasicNameValuePair("PWD","aa"));
try {
HttpEntity httpentity=new UrlEncodedFormEntity(params,"gb2312");
httpRequest.setEntity(httpentity);
HttpClient httpclient=new DefaultHttpClient();
HttpResponse httpResponse;
try {
httpResponse = httpclient.execute(httpRequest);
HttpEntity entityout = httpResponse.getEntity();
InputStream is = entityout.getContent();
is.toString();
Log.e("ok"+is.toString(), is.toString());
InputSource source = new InputSource(new InputStreamReader(is,
HTTP.UTF_8));
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db;
try {
db = dbf.newDocumentBuilder();
try {
Log.e("ok", source.toString());
Document doc = db.parse(source);
Log.e("ok1", "ok1");
NodeList resultValue = doc.getElementsByTagName("user");
resultValue.getLength();
Log.e("ok1resultValue.getLength()", resultValue.getLength()+"");
resultValue.toString();
Log.e("par"+resultValue.toString(), resultValue.toString());
Node responseNode = resultValue.item(0);
Log.e("responseNode",responseNode.toString());
String serviceResponseID = responseNode.getAttributes()
.getNamedItem("ID").getNodeValue();
String serviceResponsePWD = responseNode.getAttributes()
.getNamedItem("PWD").getNodeValue();
mTextView.setText(serviceResponseID+serviceResponsePWD);
} catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
mTextView.setText("请求错误");
}
} catch (ParserConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}