Search code examples
javaresponseksoap2

java ksoap2 login ilias


hi i'm trying to make a soap request but i don't get any response. I dont know why.. I'm following this example http://www.ilias.de/docu/ilias.php?ref_id=951&from_page=16155&cmd=layout&cmdClass=illmpresentationgui&cmdNode=57&baseClass=ilLMPresentationGUI&obj_id=16157 but i cant get any responses :( This is my code:

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 SOAPExample
{

    public String login()
    {
        String session = null;

        // first log in as a user with administrative rights and retrieve your session id
        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        SoapObject soapObject = new SoapObject("urn:ilUserAdministration", "login");
        soapObject.addProperty("client", "client3");
        soapObject.addProperty("username", "stacked");
        soapObject.addProperty("password", "overflow");
        envelope.setOutputSoapObject(soapObject);
        HttpTransportSE transport = new HttpTransportSE("http://www.ilias.de/test310/webservice/soap/server.php");
        transport.debug = true;
        try
        {
            transport.call("login", envelope);
            session = envelope.getResponse().toString();
            return session;
        }
        catch (IOException e)
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        catch (XmlPullParserException e)
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        if (session == null)
        {
            System.out.println("Your login wasn't successful");
        }
        return null;
    }

    /**
     * @param args
     */
    public static void main(String[] args)
    {
        // TODO Auto-generated method stub
        SOAPExample se = new SOAPExample();
        String sid = se.login();
        System.out.println(sid);

    }

}

Solution

  • From the little I understood from your code, I feel you are trying to authenticate a user by creating a login application.

    I have done a similar thing before on Android using ksoap.

    You can refer this. This might just give you a hint on how you should go about using ksoap.

    Hope I have helped you,

    Cheers