2009 Jun 13 2009
LMS API
IBM and the IBM Workplace Collaborative Learning, Learning Management Systems LMS applications, many users using APIs can be used to save the following code.
Read text file and saved user names and codes of the courses to be saved in the LMS is the code to realize the course assignment.
Ibm site for use in other LMS APIs apidoc examined and improved.
import java.io. *;
import java.net.URL;
import java.util.ArrayList;
import javax.xml.namespace.QName;
javax.xml.rpc.ParameterMode import;
org.apache.axis.client import. *;
/ **
* The user registers for a course ...
* Example: userid: 00000000002f9200CTEN
* @ Author Cem DOGAN December 2008
*
* /
{public class Register_to_courseWCL
public static String [] users;
public static int total = 0;
public static void main (String [] args) {try {
File file = new File ("kullanicilar_kurslar.txt");
FileInputStream fis = new FileInputStream (file);
InputStreamReader isr = new InputStreamReader (fis);
BufferedReader buff = new BufferedReader (isr);
String inputLine = "";<String> ArrayList list = new ArrayList ();
while ((inputLine = buff.readLine ())! = null) {
list.add (inputLine);
}
buff.close ();users = new String [list.size ()];
File roster_log = new File ("kursatama.log");
FileOutputStream fos = new FileOutputStream (roster_log, true);
OutputStreamWriter out = new OutputStreamWriter (fos);
BufferedWriter buf = new BufferedWriter (out);
try {
for (int i = 0; i <list.size (); i + +) {
users [i] = list.get (i);
String line [] = users [i]. Split (":");Save (line [0], row [1]);
out.write (line [0] + ":" + line [1] + "OK \ r");
}
} Catch (Exception e) {
e.printStackTrace ();
}
buf.close ();
} Catch (FileNotFoundException e) {
e.printStackTrace ();
} Catch (IOException e) {
e.printStackTrace ();
}
}public static void Save (String username, String kurskodu) throws Exception {
URL url;
try {
url = new URL ("http://IBMLMSadresiniz/lms-lmm/services/LMSRosterAPI");
Service service = new Service ();
Call call = (Call) service.createCall ();
call.setTargetEndpointAddress (url);
call.setUsername ("admin");
call.setPassword ("the Clear");
String NS_XSD = "http://www.w3.org/2001/XMLSchema";
QNAME_TYPE_STRING QName = new QName (NS_XSD, "string");
call.addParameter ("user_id", QNAME_TYPE_STRING, ParameterMode.IN);
call.addParameter ("offering_id", QNAME_TYPE_STRING,
ParameterMode.IN);
String [] params = {username, kurskodu};
call.setReturnType (QNAME_TYPE_STRING);
call.setOperationName (new QName ("LMSEnrollmentAPI",
"EnrollCourseForUser"));
call.invoke (params);} Catch (Exception e) {
throw new Exception ("An error has occurred");
}
}
}
