I have made several inquiries and this just does not get anything ...
the code of the call to the webService:
public SoapObject consultarUsuaris(String tipusUsuari, String authId){
final String metode = "consultarUsuaris";
SoapObject respostaSoap = null;
try{
//Preparem els arguments del mètode compovarLogin
Map<String,String> args = new HashMap<>();
args.put("tipusUsuari",tipusUsuari);
args.put("authId",authId);
//Fem la crida al mètode per obtenir-ne la resposta
respostaSoap = usarWebService(metode,args);
//Retornem el valor de "authId"
// return respostaSoap.getPrimitiveProperty("authId").toString();
// System.out.println(respostaSoap.getPrimitiveProperty("authId").toString());
respostaSoap.getPrimitiveProperty("nom").toString();
}
catch(Exception ex){
ex.printStackTrace();
}
return respostaSoap;
}
the request is as follows: (Example mode with the SOAP UI)
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://webservices.gamificacioc.com/">
<soapenv:Header/>
<soapenv:Body>
<web:consultarUsuaris>
<!--Optional:-->
<tipusUsuari>Alumne</tipusUsuari>
<!--Optional:-->
<authId>yGLuzgQmkp</authId>
</web:consultarUsuaris>
</soapenv:Body>
</soapenv:Envelope>
The result example would be this: (WITH SOAP UI)
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:consultarUsuarisResponse xmlns:ns2="http://webservices.gamificacioc.com/">
<llistarUsuaris>
<cognom>Maqueda Domenech</cognom>
<email>[email protected]</email>
<nom>Montse</nom>
<usuari>mmaquedadomenech</usuari>
</llistarUsuaris>
<llistarUsuaris>
<cognom>Barcia B</cognom>
<email>[email protected]</email>
<nom>Fran</nom>
<usuari>fbarciab</usuari>
</llistarUsuaris>
<llistarUsuaris>
<cognom>Ignles S</cognom>
<email>[email protected]</email>
<nom>Xavi</nom>
<usuari>xignless</usuari>
</llistarUsuaris>
</ns2:consultarUsuarisResponse>
</S:Body>
</S:Envelope>
So my idea is to get the names of all the users accessing the web service and my java code is the following:
public Object mostrarUsuaris() {
//Fem trucada a l'altre clase per recuperar el valor de authID
GamificacIOC ioc = new GamificacIOC();
//AuthId
Object authId = ioc.authId;
Object nom = null;
//Truquem la clase on tenim el metode de alta usuari
WebServiceCalls calls = new WebServiceCalls();
SoapObject resposta = calls.consultarUsuaris(WebServiceCalls.TIPUS_USUARI_ALUMNE, authId.toString());
if (resposta == null)
{
JOptionPane.showMessageDialog(null, "Error falten dades");
}
else
{
//Si els buttons son plens verifica que sigui correcte
authId= resposta.getPrimitiveProperty("authId");
// nom = resposta.getPrimitiveProperty("nom");
//authId ens dona el resultat que volem pasar per saber el tipus User
System.out.println(authId + " nom " +nom);
//Enviem l'authId per poder saber que usuari es...
String resposta2 = calls.tipusUsuari(authId.toString());
System.out.println(authId);
}
return authId;
}
}
But I get the following error:
java.lang.ClassCastException: java.util.Vector cannot be cast to org.ksoap2.serialization.SoapObject
at com.gamificacioc.utils.WebServiceCalls.cridaWebService(WebServiceCalls.java:183)
at com.gamificacioc.utils.WebServiceCalls.usarWebService(WebServiceCalls.java:130)
at com.gamificacioc.utils.WebServiceCalls.consultarUsuaris(WebServiceCalls.java:299)
at Alumnes.pantalla_LlistarAlumne.mostrarUsuaris(pantalla_LlistarAlumne.java:130)
at Alumnes.pantalla_LlistarAlumne.<init>(pantalla_LlistarAlumne.java:82)
at appEscriptori.pantalla_ProfessorGestioAlumne$3.actionPerformed(pantalla_ProfessorGestioAlumne.java:97)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Can you help me?