Java 使用HTTP在Android上发布XML

Java 使用HTTP在Android上发布XML,java,android,http,httpclient,http-post,Java,Android,Http,Httpclient,Http Post,我正在尝试在android上发布xml。同样的xml和服务器在iphone上工作得很好,但在android上我收到了无效的xml错误消息 public void postData() { HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost("http://stage.isadiasjd.com.tr/asdasdad-web/getProductDeviceServi

我正在尝试在android上发布xml。同样的xml和服务器在iphone上工作得很好,但在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>Xzcxzcxzczxc@zxczxcxczxc.com</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();
    }
} 
public void postData(){
HttpClient HttpClient=新的DefaultHttpClient();
HttpPost HttpPost=新的HttpPost(“http://stage.isadiasjd.com.tr/asdasdad-web/getProductDeviceService.do");
试一试{
StringEntity se=新的StringEntity(“254145464654654917dade51ce2c127310d1df5ee25e876e46feae470bXzcxzcxzczxc@zxczxcxczxc.com2500a7005c01903093fa268984zczczczaeawdwa2w1d3w6dec9b61afbe28f37baad819ba3e0d“,“UTF-8”);
//setContentType(“text/xml”);
setContentType(“application/atom+xml”);
httppost.setEntity(se);
HttpResponse HttpResponse=httpclient.execute(httppost);
HttpEntity当前状态=httpresponse.getEntity();
字符串ss=EntityUtils.toString(最近性);
Log.v(“http请求”,ss);
}捕获(客户端协议例外e){
//TODO自动生成的捕捉块
对数v(“ex”,“1”);
e、 printStackTrace();
}捕获(IOE异常){
//TODO自动生成的捕捉块
对数v(“ex”,“2”);
e、 printStackTrace();
}
} 

尝试应用程序/json。在Android 2上,某些型号的xml响应出现问题

您是否会复制/粘贴收到的完整错误消息(包括堆栈跟踪,如果有)?谢谢!100无效xml我想知道您的xml是否是url编码的,在这种情况下,<和>将被转换为和,从而使xml内容无效。您是否可以使用调试器向httppost的成员发送日志?