2012-08-28 11 views
6

Ho provato il metodo SOAP nella scheda samsung galaxy e funziona correttamente.Metodo SOAP Android ICS non funziona?

stesso codice testato su sandwich gelato Android e non funziona.

Qui di seguito è il mio codice,

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);    
      } 

In questo codice ho stampato httpResponse.getStatusLine(). ToString() valore stampato come questo HTTP/1.1 200 OK codice 200

ma il valore della linea diventa nullo.

grazie. ..

risposta

0

Prova questo,

politica StrictMode.ThreadPolicy = new StrictMode.ThreadPolicy.Builder() permitAll() costruire(); StrictMode.setThreadPolicy (criterio);

+0

dove dovrei usare questo codice nel mio progetto ... ??? – Jeeva123

+0

Prima di chiamare le funzioni relative alla rete. Meglio usare sotto la dichiarazione della classe principale. – chain

Problemi correlati