Checking envelope with Ksoap2 (Android)
Asked Answered
A

2

13

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

Adversative answered 18/1, 2012 at 17:40 Comment(0)
W
34

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.

Wabble answered 18/1, 2012 at 17:51 Comment(1)
androidHttpTransport.requestDump give me nullTraceable
E
2

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).

Ern answered 6/11, 2012 at 1:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.