Search code examples
androidweb-servicessoapksoap2envelope

Checking envelope with Ksoap2 (Android)


Coming from iOS I'm having a pretty hard time with web services in Android. I've spent several hours trying examples, reading blogs, and communicating successfully with a web service still seems to be a question of luck....

Bottom line and I want to be able to see the envelope that is being sent. In iOS I can just look at the XML message that is going to be sent, compare it to SoapUI or something like that and understand what is wrong. Can't we do that? Before the call output the XML to a System.out.print?

I would also like to do the same thing to the response, get the plain http response, because Ksoap2 exceptions are quite poor.

Sorry if this is a pretty basic question but I'm getting a bit frustrated :(


Solution

  • After you have created your HttpTransportSE androidHttpTransport you can add the line:

     androidHttpTransport.debug = true; 
    

    After calling androidHttpTransport.call(SOAP_ACTION, envelope); you can get the request and response in XML format from the two String variables:

    androidHttpTransport.requestDump;
    androidHttpTransport.responseDump;
    

    You can print these values to the Log or access them inside the debug mode.