Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Current »

Feb. 21, 2007

From Jim Martino:

This may be a matter of taste, but I set this in sakai.properties:

  1. Indicates whether or not we allow web-service logins
    webservices.allowlogin=true

One less file to change when upgrading.

Aaron Gerow
Example of a Perl script connecting to Sakaiscript:

Paul, our scripts bind to Axis something like this in Perl:

use SOAP::Lite;
...
my $loginURI = "https://sakai.plu.edu/sakai-axis/SakaiLogin.jws?wsdl";
my $scriptURI = "https://sakai.plu.edu/sakai-axis/SakaiScript.jws?wsdl";
($loginsoap = SOAP::Lite
-> proxy($loginURI)
-> uri($loginURI));
$session = $loginsoap->login($app_user, $app_password)->result;
$scriptsoap = SOAP::Lite
-> proxy($scriptURI)
-> uri($scriptURI));
...
$scriptsoap->addNewSite($session, $siteid, $title,
$desc, $sdesc, $icon_url,
"", $false, $JOIN_ROLE, $false,
$false, "", $SITE_TYPE);
...

Notice the first two URIs. I had some trouble with our dev-box that was
worked around by binding to something like
'http://sakai.plu.edu:8080/...'. Notice this isn't SSL, and goes
directly to Tomcat (no Apache). Another little check is to browse to
something like https://sakai.plu.edu/sakai-axis/SakaiScript.jws and see
what Axis gives you. Upon clicking the link at that page you should get
some WSDL-style XML. If not, you might check out Apache or permissions
of the jws files. Here you might also get a sort of syntax error if
SakaiScript.jws is in bad shape.

Mar. 12,2007

For users creation first you need to be authenticated.

I suggest you give a glance to how to create web services clients with axis
for java.

The following steps could prove useful.

download axis for java,

Set environment variables (it must include the following):

AXIS_HOME=absolute path to axis
AXIS_LIB=%AXIS_HOME%\lib
CLASSPATH=%AXIS_LIB%\axis.jar;%AXIS_LIB%\commons-discovery-0.2.jar;%AXIS_LIB%\commons-logging-1.0.4.jar;%AXIS_LIB%\jaxrpc.jar;%AXIS_LIB%\saaj.jar;%AXIS_LIB%\log4j-

1.2.8.jar;%AXIS_LIB%\wsdl4j-1.5.1.jar

then, you can execute in command line (with sakai up):

java org.apache.axis.wsdl.WSDL2Java " http://localhost:8080/sakai-axis/SakaiLogin.jws?wsdl"
java org.apache.axis.wsdl.WSDL2Java
"http://localhost:8080/sakai-axis/SakaiScript.jws?wsdl
"

2. After that you can use SakaiScript in java in similar ways as others has
explained before.

For example, look at this (in python): https://source.sakaiproject.org/svn/webservices/trunk/axis/test/sakaiscript/

or this (very complete one): https://source.sakaiproject.org/contrib/sakaiscript/clientexamples/perl/perlsample.pl

3. Create java classes and import the axis stuff:

import SakaiScript_jws.*;
import SakaiLogin_jws.*;

/**
*
* @author Alex. S.
*/
public class Main
{
public static void main (String[] args) throws Exception
{
SakaiLoginService loginService = new SakaiLoginServiceLocator ();
SakaiLogin mySakaiLogin = service.getSakaiLogin ();

SakaiScriptService scriptService = new SakaiScriptServiceLocator ();
SakaiScript mySakaiScript = scriptService.getSakaiScript ();

System.out.println("trying login...");
String sid = mySakaiLogin .login ("admin", "admin");

System.out.println("SESSION ID:");
System.out.println(sid);
System.out.println("logged, and thereafter we can do a lot of
interesting stuff with users and sites");

// in the documentation you can find more details for properly use of
SakaiLogin and SakaiScript
// with these you can create users, sites, etc...

}
}

On 3/12/07, onur < onursirin@sabanciuniv.edu> wrote:

>
>
> Hello,
>
> I need to import thousands of users and sites into sakai with sakaiscript
> but i couldn't cover the matter at all.
>
> I glanced Sakai docs named sakaiscript-2.1 which is located in
> sakai-src/reference/docs/webservices/.
> First, i added this entry below:
> webservices.allowlogin=true
>
> Then, i used a script named UserWebService.jws and there are some comments
> in sakai docs below:
>
> If you put the above code snippet into a file named UserWebService.jws
> and placed it into the sakai-axis directory, you could then connect to
> it using the URL, "http://pedagogy:8080/sakai-axis/UserWebService.jws?wsdl
> ".
> Viola, we've just created a web service to add new users to Sakai!
>
> I think that i did it correctly but it's failed.
>

> import org.sakaiproject.api.kernel.session.cover.SessionManager;
> import org.sakaiproject.service.legacy.user.User;
> import org.sakaiproject.service.legacy.user.cover.UserDirectoryService ;
>
> public class UserWebService {
> public String addNewUser( String sessionid, String userid, String
> firstname, String lastname, String email, String type, String password)
> {
> Session s = SessionManager.getSession (id);
> s.setActive();
> SessionManager.setCurrentSession(s);
>
> try {
> User addeduser = null;
> addeduser = UserDirectoryService.addUser(userid,
> firstname, lastname, email, password, type, null);
> }
> catch (Exception e) {
> return e.getClass().getName() + " : " +
> e.getMessage();
> }
> return "success";
> }
> }

>
> I think any of the below classes are not exist on system. So, i can't
> figure
> it out how to execute this script.
> import org.sakaiproject.api.kernel.session.cover.SessionManager;
> import org.sakaiproject.service.legacy.user.User;
> import org.sakaiproject.service.legacy.user.cover.UserDirectoryService;
>
> Could you explain this situation respectively?
>
> Any response would be greatly appreciated...
>
> Regards
> –
> View this message in context: http://www.nabble.com/Importing-Users-and-Sites-into-Sakai-with-.JWS-tf3389743.html#a9435451
>
> Sent from the sakai-dev mailing list archive at Nabble.com.

  • No labels