我正在使用下面的代码片段从给定的 wsdl url 获取用户详细信息,它只返回第一个用户的信息而不是整个列表,我该如何更正它以便打印整个用户详细信息?我需要它在 Android 上运行,所以我使用 ksoap-2-android 库。
请记住,我完全是 web 服务和 wsdl 的新手。我已经尝试理解阅读,但没有取得很多成就。
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) {};
}
更新:System.out.println(result.toString()); 给了这个