I'm using the code snippet below to get user details from a wsdl url given, it returns only first user's informations instead of whole list, how may i correct it so that it'll print whole user details ? I need it to run on Android so i'm using ksoap-2-android library.
Please keep in mind that i'm completely newbie to web service and wsdl stuff. I've tried understanding reading but not achieved a lot.
package parsewsdl;
import java.io.IOException;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import org.xmlpull.v1.XmlPullParserException;
public class ParseWSDL {
private static final String NAMESPACE = "http://domain.intern.bits.com";
private static final String METHOD_NAME = "getUserList";
private static final String URL =
"http://www.bulusalim.com:12000/BitsMobileInternHomeWork/services/UserWebService?wsdl";
private static final String SOAP_ACTION = "getUserListResponse";
public static void main(String[] argv) {
SoapObject soapObject = new SoapObject(NAMESPACE, METHOD_NAME);
SoapSerializationEnvelope env = new SoapSerializationEnvelope(SoapEnvelope.VER11);
env.setOutputSoapObject(soapObject);
HttpTransportSE con = new HttpTransportSE(URL);
try {
con.call(SOAP_ACTION, env);
SoapObject result = (SoapObject) env.bodyIn;
SoapObject dets = (SoapObject) result.getProperty("getUserListReturn");
System.out.println(dets.getProperty("email").toString());
} catch (IOException | XmlPullParserException e) {};
}
Update : System.out.println(result.toString()); gives this
I don't know if it's the most sufficient or appropriate way but I found such solution :
...
SoapObject result = (SoapObject) env.bodyIn;
final int size = result.getPropertyCount();
for (int i = 0; i < size; i++) {
SoapObject tempObj = (SoapObject) result.getProperty(i);
// accessing operations with the name name and surname
tempObj.getPropertyAsString("name");
tempObj.getPropertyAsString("surname");
...