1
我想在android上發佈xml。同樣的xml和服務器在iPhone上完美工作,但在Android我得到無效的XML錯誤信息。使用HTTP POST Android XML
public void postData() {
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://stage.isadiasjd.com.tr/asdasdad-web/getProductDeviceService.do");
try {
StringEntity se = new StringEntity("<customer><districtId>2541</districtId><barcode>45464654654917</barcode><udid>dade51ce2c127310d1df5ee25e876e46feae470b</udid><email>[email protected]</email><hashCode>2500a7005c01903093fa268984zczczczaeawdwa2w1d3w6dec9b61afbe28f37baad819ba3e0d</hashCode></customer>", "UTF-8");
// se.setContentType("text/xml");
se.setContentType("application/atom+xml");
httppost.setEntity(se);
HttpResponse httpresponse = httpclient.execute(httppost);
HttpEntity resEntity = httpresponse.getEntity();
String ss = EntityUtils.toString(resEntity);
Log.v("http req", ss);
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
Log.v("ex","1");
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
Log.v("ex","2");
e.printStackTrace();
}
}
您會複製/粘貼收到的完整錯誤消息(包括堆棧跟蹤,如果有的話)?謝謝! – Shlublu
我想知道你的XML是否是URL編碼的,在這種情況下< and >將已轉化的<和>,使得XML內容無效。用調試器你會對httppost的成員感到厭煩嗎? – Shlublu