Reputation: 9020
The SoapObject
is the response from a SOAP based web service.
I know it contains XML
data because I tested the web service on www.soapclient.com.
Now, I want to use XMLPullParser
to parse the response. XMLPullParser
takes an InputStream
, so is there a way to convert the SoapObject
into an InputStream
?
Upvotes: 0
Views: 926
Reputation: 781
You may redefine envelope class by replacing parseBody method. Here is example of inheriting class:
public class SSEnv extends SoapSerializationEnvelope
{
public void parseBody(XmlPullParser parser) throws IOException, XmlPullParserException{
//Yes! its modified code snipet from android dev page :)
int eventType = parser.getEventType();
while (!(eventType == XmlPullParser.END_TAG && parser.getName().equalsIgnoreCase("body"))) {
if(eventType == XmlPullParser.START_DOCUMENT) {
System.out.println("Start document");
} else if(eventType == XmlPullParser.START_TAG) {
System.out.println("Start tag "+parser.getName());
} else if(eventType == XmlPullParser.END_TAG) {
System.out.println("End tag "+parser.getName());
} else if(eventType == XmlPullParser.TEXT) {
System.out.println("Text "+parser.getText());
}
eventType = parser.next();
}
}
}
Remember that parse method from SoapEnvelope require end tag of "Body", thats why there is condition in loop "while (!(eventType == XmlPullParser.END_TAG && parser.getName().equalsIgnoreCase("body")))". And ofcourse after getRequest and bodyIn will be null after that modification.
Second way is to parse reponseDump from HttpTransportSE but its a kind of terrorism ;)
kind regards Marcin
Upvotes: 1