2012-08-28 81 views
6

我測試在三星Galaxy Tab SOAP方法和工作正常。Android ICS 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代碼200

但行值變爲null。

感謝。 。

回答

0

試試這個,

StrictMode.ThreadPolicy政策=新StrictMode.ThreadPolicy.Builder()permitAll()建(); StrictMode.setThreadPolicy(策略);

+0

,我應該用在我的項目這段代碼... ??? – Jeeva123

+0

調用網絡相關的功能之前。最好在主類的聲明下使用。 – chain