0

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

NotCamelCase
  • 1,073
  • 1
  • 10
  • 18
  • It seems to me that the service only provides you with a handfull of usernames. There is no limitation in the code. So, either limitation is wanted from the web service provider or you need to use an other web service command by changing the METHOD_NAME variable and the parameter in result.getProperty(""). What does the web service documentation say? – nullpointr May 27 '12 at 20:20
  • I've got nothing but the url, i've been just told to reflect user lists and details onto an android app. also, System.out.println(result.toString()); gives this : http://pastebin.com/AcFpbG3i . I need to parse it somehow but i couldn't get it yet.. – NotCamelCase May 27 '12 at 20:23

1 Answers1

-1

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");
...
NotCamelCase
  • 1,073
  • 1
  • 10
  • 18