Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 :(

like image 925
Joao Sousa Avatar asked Jan 18 '12 17:01

Joao Sousa


2 Answers

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.

like image 158
ajgarn Avatar answered Nov 20 '22 18:11

ajgarn


Use a TCP/IP monitor, such as one that comes in Eclipse (Window->Show View->Debug->TCP/IP Monitor). I would argue that printing the XML envelope does not belong in the code, as it is only for debugging. If your webservice is listening on port 8080 you would configure the monitor to listen on port 8081 and to monitor port 8080. Then point your SOAP client at port 8081. That way the TCP/IP monitor will recieve the XML, display it, then forward it to the actual service at 8080. It will do the same for response. This will also work SoapUI (just point it at port 8081).

like image 2
mark.kedzierski Avatar answered Nov 20 '22 19:11

mark.kedzierski