Android ICS SOAP方法不起作用?

时间:2012-08-28 06:53:15

标签: android soap xml-parsing

我在 samsung galaxy tab 中测试了SOAP方法,并且工作正常。

我在 Android冰淇淋三明治上测试的相同代码并没有用。

以下是我的代码,

HttpPost httppost = new HttpPost("xxxxxx");        
            httppost.setHeader("Content-type", "text/xml; charset=utf-8");
            httppost.setHeader("SOAPAction", SoapAction);

            StringEntity se1 = new StringEntity(env,HTTP.UTF_8);
            se1.setContentType("text/xml");  
            se1.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "text/xml; charset=utf-8"));
            httppost.setEntity(se1);  

            HttpClient httpclient = new DefaultHttpClient();
            BasicHttpResponse httpResponse = (BasicHttpResponse) httpclient.execute(httppost);

            System.out.println("res------"+httpResponse.getStatusLine().toString()+" code  "+httpResponse.getStatusLine().getStatusCode());

            //Checking response 
            if(httpResponse!=null){
                inputStream = httpResponse.getEntity().getContent();


                BufferedReader r = new BufferedReader(new InputStreamReader(inputStream));
                StringBuilder total = new StringBuilder();
                String line="";
                try {
                    while ((line = r.readLine()) != null) {
                        total.append(line);
                    }
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                System.out.println("line----"+line);            
            }

在这段代码中,我打印了 httpResponse.getStatusLine()。toString()这样的打印值 HTTP / 1.1 200 OK code 200

但行值变为空。

感谢。

1 个答案:

答案 0 :(得分:0)

试试这个,

StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()。permitAll()。build();       StrictMode.setThreadPolicy(策略);