import java.net.URL;
import de.tum.in.www_db.UniVerwaltung_wsdl.*;

/**
 * 
 * Simple client class to invoke the UniVerwaltung service. The program should be
 * called the following way: java Client -l<url> <ProfName>, e.g., java Client
 * -lhttp://localhost:8080/axis/services/UniVorlesungen Sokrates
 */
public class Client {

  public static void main(String args[]) throws Exception {
    UniVerwaltungService uvws = new UniVerwaltungServiceLocator();

    // get the Port
    URL url = new URL("http://localhost:8080/axis/services/UniVerwaltung");

    UniVerwaltungPortType uv = uvws.getUniVerwaltung(url);

    // the invocation of the service:
    String pName = "Sokrates";
    String sName = "Fichte";
    String vTitel = "Logik";

    System.out.println("Lehrumfang von Professor " + pName + ": "
        + uv.getLehrUmfangVonProfessor(pName));

    System.out.println("Eintragen von " + sName + " hört " + vTitel);

    uv.setHoertVorlesung(sName, vTitel);

    VorlesungslistenTyp list = uv.getVorlesungslisteVonProfessor(pName);
    System.out.println("Vorlesungsliste von Professor " + pName);
    System.out.println("Titel \t SWS \t VorlNr");
    if (list.getVorlesung() != null) {
      for (Object o : list.getVorlesung()) {
        VorlesungslistenTypVorlesung vorl = (VorlesungslistenTypVorlesung) o;
        System.out.println(vorl.getTitel() + "\t" + vorl.getSWS() + "\t"
            + vorl.getVorlNr());
      }
    }
  }
}
