2013-01-14 12 views
7

Mam trudny czas próbować uzyskać wygenerowany XML z moim SoapRequest. To jest mój kod:Gdzie wyświetlić wygenerowany plik XML (KSOAP2)

SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); 
     SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); 

     PropertyInfo propInfo=new PropertyInfo(); 
     propInfo.setName("arg0"); 
     propInfo.setType(PropertyInfo.STRING_CLASS); 
     propInfo.setValue(sessionId); 

     request.addProperty(propInfo); 

     // Sending the array representing our board: 

     Fields fieldsVector = new Fields(); 

     for (int i=0; i<65; i++) { 

      fieldsVector.add(move[i].toString()); 

     } 

     PropertyInfo fieldsPropertyInfo = new PropertyInfo(); 
     fieldsPropertyInfo.setName("fields"); 
     fieldsPropertyInfo.setValue(fieldsVector); 
     fieldsPropertyInfo.setType(fieldsVector.getClass()); 

     request.addProperty(fieldsPropertyInfo); 

     PropertyInfo sessionPropertyInfo = new PropertyInfo(); 
     sessionPropertyInfo.setName("arg0"); 
     sessionPropertyInfo.setType(PropertyInfo.STRING_CLASS); 
     sessionPropertyInfo.setValue(sessionId); 
     request.addProperty(sessionPropertyInfo); 

     envelope.setOutputSoapObject(request); 

     envelope.addMapping(NAMESPACE, "fields", new Fields().getClass()); 

     HttpTransportSE androidHttpTransport = new HttpTransportSE(WSDL_URL); 
     // androidHttpTransport.debug = true; 


     try { 
      androidHttpTransport.call(SOAP_ACTION, envelope); 
     } catch (Exception e) { 
      throw new RuntimeException("Unexpected exception", e); 
     } 

     try { 
      SoapPrimitive resultsRequestSOAP = (SoapPrimitive) envelope.getResponse(); 
     } catch (SoapFault e) { 
      System.out.println("Error adding move: " + e.faultstring);//można to ładnie jakoś pokazać na ekranie 
      throw e; 
     } 
    } 

Jak widać próbowałem ustawić tryb debugowania, ale to nie działa. Gdzie powinienem zobaczyć wydruk?

Odpowiedz

19

Prawie osiągnął odpowiedź, ustawić androidHttpTransport.debug = true i połączenia zrzutu xml jak poniżej:

androidHttpTransport.debug = true; 
    androidHttpTransport.call(SOAP_ACTION, envelope); 
    Log.d("dump Request: " ,androidHttpTransport.requestDump); 
    Log.d("dump response: " ,androidHttpTransport.responseDump); 
+4

Wystarczy być ostrożnym i napisać ostatnie 2 linie po otrzymaniu wyniku, to znaczy (onPostExecute) na przykład. –

Powiązane problemy