URGENT HELP - SAKAI 21 webservice perl scripts

86 views
Skip to first unread message

Alaa Nizar

unread,
Aug 9, 2021, 6:47:00 AM8/9/21
to Steve Swinsburg, s.swi...@lancaster.ac.uk, Matthew Jones, Earle Nietzel, Sam Ottenhoff, sakai-dev

Pleas help: URGENT

I worked with Steve's perl scripts for years now.

 

 

I changed these lines:

#loginUrl = serverUrl + '/sakai-axis/SakaiLogin.jws?wsdl'

#scriptUrl = serverUrl + '/sakai-axis/SakaiScript.jws?wsdl';

with the following:

loginUrl = serverUrl + "/sakai-ws/soap/login?wsdl"

scriptUrl = serverUrl + "/sakai-ws/soap/sakai?wsdl"

BUT still, I have this error: Use of uninitialized value $sessionId in concatenation (.) or string at addUser_21.pl line 65.

 

here's the perl script in question:

#!/usr/bin/perl -w

#
# Perl script to add a list of users to sakai and enroll
# them in a given course.  Users are read from a csv formatted
# file with lines like the following:
#
# netId;firstName;lastName;userEmail;role;password
#

use SOAP::Lite;

# Sakai service location constants
use constant {
    LOGIN_WS => "/sakai-ws/soap/login?wsdl",
    SCRIPT_WS => "/sakai-ws/soap/sakai?wsdl",
    IIHEM_ADDR => "\@iihem.ac.ma",
#    IIHEM_ADDR => "",
};

# Initialize variables from command line parameters
my $userlist = shift;
my $host = shift;
my $id = shift;
my $password = shift;

# Routine to display some usage information
sub usage {
    print "\nUsage: useradd.pl filename host username password [siteId] [roleId]\n\n";
    print "e.g.  useradd.pl userlist.csv http://localhost:8080 admin admin_pass\n\n";
}


# Routine to connect to sakai login service
sub sakaiLogin {
    return $host.LOGIN_WS;
}

# Routine to connect to
sub sakaiScript {
    return $host.SCRIPT_WS;
}

# Routine to create an email address
sub makeEmail {
    my $username = shift;
    return $username.IIHEM_ADDR;
}

# If either are undefined, display usage and exit
if (!$userlist ||
    !$host ||
    !$id ||
    !$password) {
    &usage;
    exit;
}
# Open the file containing the user list
open(USERLIST, $userlist) || die "Unable to open $userlist!\n";

# Initialize SOAP client
$loginClient = SOAP::Lite->new(proxy => &sakaiLogin($host));
$sessionId = $loginClient->login($id, $password)->result;

print "SESSION_ID: ".$sessionId."\n";

$scriptClient = SOAP::Lite->new(proxy => &sakaiScript($host));

while () {
    chop;
    ($netId, $firstName, $lastName, $userEmail, $role, $password) = split(/;/);
    my $email = &makeEmail($userEmail);

    print "Attempting to add user:\n";
    print "\tEID:\t\t".$netId."\n";
    print "\tFIRST_NAME:\t".$firstName."\n";
    print "\tLAST_NAME:\t".$lastName."\n";
    print "\tEMAIL:\t".$email."\n";
    print "\tRole:\t".$role."\n";
    print "\tPASSWORD:\t".$password."\n";

    my $result = $scriptClient->addNewUser($sessionId,
                                           $netId,
                                           $firstName,
                                           $lastName,
                                           $email,
                                           $role,
                                           $password)->result;

    print "Result: ".$result."\n";

    print "\n";
}

$loginClient->logout($sessionId);

close(USERLIST);

 

Thank you so much for your help.

 

Attached is the the perl script embedded above.



--

Alaa NIZAR, BA in MIS, LPIC
IIHEM Network Services Manager
+212 661 99 26 01
www.iihem.ac.ma

addUser.pl

Matthew Jones

unread,
Aug 9, 2021, 10:24:45 AM8/9/21
to Alaa Nizar, Steve Swinsburg, s.swi...@lancaster.ac.uk, Matthew Jones, Earle Nietzel, Sam Ottenhoff, sakai-dev
I'm not sure what's wrong with the Perl SOAP and don't know much about SOAP Lite.  But I know that this Python script on  https://confluence.sakaiproject.org/display/WEBSVCS/How+to+use+the+Sakai+Web+Services still works fine.

Maybe you're missing creating a service and using this pattern with the Sakai WSLwould get it to work?
  use SOAP::Lite;
  print SOAP::Lite
    -> service('http://www.xmethods.net/sd/StockQuoteService.wsdl')
    -> getQuote('MSFT');


--
You received this message because you are subscribed to the Google Groups "Sakai Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sakai-dev+...@apereo.org.
To view this discussion on the web visit https://groups.google.com/a/apereo.org/d/msgid/sakai-dev/aceccde765e05f34f78932dedbd00c70.squirrel%40webmail.iihem.ac.ma.

Earle Nietzel

unread,
Aug 9, 2021, 10:45:11 AM8/9/21
to Matthew Jones, Alaa Nizar, Steve Swinsburg, s.swi...@lancaster.ac.uk, Matthew Jones, Sam Ottenhoff, sakai-dev
Can also look at this script

-earle

alaanizar

unread,
Aug 10, 2021, 8:58:00 AM8/10/21
to Earle Nietzel, Matthew Jones, Steve Swinsburg, s.swi...@lancaster.ac.uk, Matthew Jones, Sam Ottenhoff, sakai-dev
Thank you for the link.
I saw it yesterday, it's based on bash language. I'll try to convert all the perl scripts to either Bash or Python. 

The problem with thise perl scripts on Sakai 21 is that they don't give any meaningful error.
The same scripts were valid until version 10. All they need is SOAP::Lite package to be installed. 

By the way, the server is a Centos 8.2, with Selinux disabled. Even the firewalld is off. The problem is in the Print line when the script tries to get the $sessionId info.

It's either the connection didn't go through or the connection function has changed since.

Just thinking ! 

I hope Steve, the coder of those scripts, can update them, or have a look of what's wrong with "his" scripts, with a BIG thank you.

Thank you all once again.

Will Keep you updated!



Envoyé depuis mon appareil Galaxy


-------- Message d'origine --------
De : 'Earle Nietzel' via Sakai Development <saka...@apereo.org>
Date : 09/08/2021 16:35 (GMT+00:00)
À : Matthew Jones <matthe...@learnxp.com>
Cc : Alaa Nizar <alaa...@iihem.ac.ma>, Steve Swinsburg <steve.s...@gmail.com>, s.swi...@lancaster.ac.uk, Matthew Jones <mat...@longsight.com>, Sam Ottenhoff <otte...@longsight.com>, sakai-dev <saka...@apereo.org>
Objet : Re: [sakai-dev] URGENT HELP - SAKAI 21 webservice perl scripts

To view this discussion on the web visit https://groups.google.com/a/apereo.org/d/msgid/sakai-dev/CAMddi31AyEPJxf2-CK%3D%3D1mf-d_U%3DyPU0qPq1EP9cWuMNCRmj3g%40mail.gmail.com.

--
This message has been scanned for viruses and dangerous content
, and is believed to be clean.

Steve Swinsburg

unread,
Aug 11, 2021, 1:53:12 AM8/11/21
to alaanizar, Earle Nietzel, Matthew Jones, s.swi...@lancaster.ac.uk, Matthew Jones, Sam Ottenhoff, sakai-dev
Hi!

Wow those scripts are still going strong :)

I remember that error and it was when the server didn't return the sessionId properly. So something is up with the authentication and getting the response.
It's been a very long time since I used them though sorry. 

regards,
Steve

alaanizar

unread,
Aug 11, 2021, 3:19:04 AM8/11/21
to Steve Swinsburg, Earle Nietzel, Matthew Jones, s.swi...@lancaster.ac.uk, Matthew Jones, Sam Ottenhoff, sakai-dev
Hi steve,

They are still alive znd working fine with Sakai 10 and earlier.

Can you please give some time to see what is wrong with the session id information code?

We use those scripts heavily and can not upgrade Sakai without them working right.

Thank you all 



Envoyé depuis mon appareil Galaxy


-------- Message d'origine --------
De : Steve Swinsburg <steve.s...@gmail.com>
Date : 11/08/2021 07:43 (GMT+00:00)
À : alaanizar <alaa...@iihem.ac.ma>
Cc : Earle Nietzel <ea...@longsight.com>, Matthew Jones <matthe...@learnxp.com>, s.swi...@lancaster.ac.uk, Matthew Jones <mat...@longsight.com>, Sam Ottenhoff <otte...@longsight.com>, sakai-dev <saka...@apereo.org>

Alaa Nizar

unread,
Aug 11, 2021, 5:01:02 AM8/11/21
to Matthew Jones, Alaa Nizar, Steve Swinsburg, s.swi...@lancaster.ac.uk, Matthew Jones, Earle Nietzel, Sam Ottenhoff, sakai-dev

Hi,

I confirm that Python script is working just fine. Had to change debug=1 to debug=0.

Now trying to modify it for the other functions like: change pass, copySite, addUserToSite, remUser, remUserFromSite, ...etc

Still waiting for Steve possible hack to make those perl scripts working again.

Thank you Guys,

 


I'm not sure what's wrong with the Perl SOAP and don't know much about SOAP

Lite. But I *know* that this Python script on


https://confluence.sakaiproject.org/display/WEBSVCS/How+to+use+the+Sakai+Web+Services
still works fine.

Maybe you're missing creating a service and using this pattern
with the Sakai
WSLwould get it to work?

use SOAP::Lite;
print SOAP::Lite
-> service('http://www.xmethods.net/sd/StockQuoteService.wsdl')
-> getQuote('MSFT');



> Alaa NIZAR, BA in MIS, LPIC
> IIHEM Network Services Manager
> +212 661 99 26 01
> www.iihem.ac.ma
>
> --
> You received this message because you are subscribed to the Google Groups
> "Sakai
Development" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sakai-dev+...@apereo.org.
> To view this discussion on the web visit
> https://groups.google.com/a/apereo.org/d/msgid/sakai-dev/aceccde765e05f34f78932dedbd00c70.squirrel%40webmail.iihem.ac.ma
>
> .
>

--
You received this message because you are subscribed to the Google Groups "Sakai
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sakai-dev+...@apereo.org.

To view this discussion on the web visit https://groups.google.com/a/apereo.org/d/msgid/sakai-dev/CACqbowt%2B3XQO1-NaonmaYWamB2sm_JHeFtRxmJMSbaHB9z0bBw%40mail.gmail.com.



--
This message has been scanned for viruses and dangerous content

, and believed to be clean.

Alaa Nizar

unread,
Aug 11, 2021, 5:04:21 AM8/11/21
to Matthew Jones, Alaa Nizar, Steve Swinsburg, s.swi...@lancaster.ac.uk, Matthew Jones, Earle Nietzel, Sam Ottenhoff, sakai-dev

Hi Matthew,

Here's what I get when adding StockQuoteService:

Service description 'http://www.xmethods.net/sd/StockQuoteService.wsdl' can't be loaded: 500 Can't connect to www.xmethods.net:80 (Name or service not known)

using both http and https.

Yours,

 

 


I'm not sure what's wrong with the Perl SOAP and don't know much about SOAP

Lite. But I *know* that this Python script on


https://confluence.sakaiproject.org/display/WEBSVCS/How+to+use+the+Sakai+Web+Services
still works fine.

Maybe you're missing creating a service and using this pattern
with the Sakai
WSLwould get it to work?

use SOAP::Lite;
print SOAP::Lite
-> service('http://www.xmethods.net/sd/StockQuoteService.wsdl')
-> getQuote('MSFT');



> Alaa NIZAR, BA in MIS, LPIC
> IIHEM Network Services Manager
> +212 661 99 26 01
> www.iihem.ac.ma
>
> --
> You received this message because you are subscribed to the Google Groups
> "Sakai
Development" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sakai-dev+...@apereo.org.
> To view this discussion on the web visit
> https://groups.google.com/a/apereo.org/d/msgid/sakai-dev/aceccde765e05f34f78932dedbd00c70.squirrel%40webmail.iihem.ac.ma
>
> .
>

--
This message has been scanned for viruses and dangerous content
, and believed to be clean.



Alaa Nizar

unread,
Aug 11, 2021, 5:29:47 AM8/11/21
to Matthew Jones, Alaa Nizar, Steve Swinsburg, s.swi...@lancaster.ac.uk, Matthew Jones, Earle Nietzel, Sam Ottenhoff, sakai-dev

BIG SUCCESS!

I managed to move all Sakai functions that were in perl scripts to Python3 script.

It works just fine.

Please where can I find all Sakai webservices calls?

Thank you

 

 


I'm not sure what's wrong with the Perl SOAP and don't know much about SOAP

Lite. But I *know* that this Python script on


https://confluence.sakaiproject.org/display/WEBSVCS/How+to+use+the+Sakai+Web+Services
still works fine.

Maybe you're missing creating a service and using this pattern
with the Sakai
WSLwould get it to work?

use SOAP::Lite;
print SOAP::Lite
-> service('http://www.xmethods.net/sd/StockQuoteService.wsdl')
-> getQuote('MSFT');



> Alaa NIZAR, BA in MIS, LPIC
> IIHEM Network Services Manager
> +212 661 99 26 01
> www.iihem.ac.ma
>
> --
> You received this message because you are subscribed to the Google Groups
> "Sakai
Development" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sakai-dev+...@apereo.org.
> To view this discussion on the web visit
> https://groups.google.com/a/apereo.org/d/msgid/sakai-dev/aceccde765e05f34f78932dedbd00c70.squirrel%40webmail.iihem.ac.ma
>
> .
>

--
You received this message because you are subscribed to the Google Groups "Sakai
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sakai-dev+...@apereo.org.

To view this discussion on the web visit https://groups.google.com/a/apereo.org/d/msgid/sakai-dev/CACqbowt%2B3XQO1-NaonmaYWamB2sm_JHeFtRxmJMSbaHB9z0bBw%40mail.gmail.com.



--
This message has been scanned for viruses and dangerous content
, and believed to be clean.



Alaa Nizar

unread,
Aug 11, 2021, 11:07:10 AM8/11/21
to sakai-dev, Earle Nietzel, Matthew Jones, Steve Swinsburg, s.swi...@lancaster.ac.uk, Matthew Jones, Sam Ottenhoff

Hi all,

I found this web service to activate/deactivate a user from a given site. However, what is the function to activate/deactivate a user from the whole system!!

From the web interface, I can make a user enabled or disabled. what is the corresponding web service function?

Thank you

   /**
     * Activate/Deactivate an user in a site
     *
     * @param     sessionid     a valid session id
     * @param     siteid         the id of the site
     * @param     eid         the id of the user to activate/deactivate
     * @param     active         true for activate, false to deactivate
     * @return    true if all went ok or exception otherwise
     * @return    Success or exception message
     */

Alaa Nizar

unread,
Aug 12, 2021, 7:38:04 AM8/12/21
to Matthew Jones, Alaa Nizar, Steve Swinsburg, s.swi...@lancaster.ac.uk, Matthew Jones, Earle Nietzel, Sam Ottenhoff, sakai-dev

Hi,

I'm using the proposed Python3 scripts. They are working fine EXCEPT for two webservices: copySite and addNewSite. Below are the code for copySite.py and copySite.csv and the error I'm getting from sakai 21:

copySite.py:

"""
Python3
"""
import os
import sys
import csv
from zeep import Client

##################### EDIT HERE #####################

username = 'admin_u'
password = 'admin_p'

#serverUrl = "https://trunk-mysql.nightly.sakaiproject.org"
#serverUrl = "https://qa11-oracle.nightly.sakaiproject.org"
serverUrl = "http://localhost:8080"

filename = "copySite.csv"

debug = 0

############## DO NOT EDIT BELOW HERE  ##############
############## OR DO IF YOU WANT TO :p ##############

#loginUrl = serverUrl +  '/sakai-axis/SakaiLogin.jws?wsdl'
#scriptUrl = serverUrl + '/sakai-axis/SakaiScript.jws?wsdl';

loginUrl = serverUrl + "/sakai-ws/soap/login?wsdl"


scriptUrl = serverUrl + "/sakai-ws/soap/sakai?wsdl"

loginProxy = Client(loginUrl)
scriptProxy = Client(scriptUrl)

if debug:
    print("loginUrl: {0}".format(loginUrl))

sessionId = loginProxy.service.login(username, password)

with open(filename, 'r') as csvFile:
    dialect = csv.Sniffer().sniff(csvFile.read(1024))
    csvFile.seek(0)
    reader = csv.reader(csvFile, dialect)

    for row in reader:
        siteidtocopy = row[0]
        newsiteid = row[1]
        title = row[2]
        description = row[3]
        shortdesc = row[4]
        iconurl = row[5]
        infourl = row[6]
        joinable = row[7]
        joinerrole = row[8]
        published = row[9]
        publicview = row[10]
        skin = row[11]
        type = row[12]

        if (debug):
            print("OrigSite: {0} Site: {1} Title: {2} description: {3} shortdesc: {4} iconurl: {5} infourl: {6} joinable: {7} joinerrole: {8} published: {9} publicview: {10}  skin: {11} type: {12}".format(siteidtocopy, newsiteid, title, description, shortdesc, iconurl, infourl, joinable, joinerrole, published, publicview,  skin, type))
        else:
            result = scriptProxy.service.copySite(sessionId, siteidtocopy, newsiteid, title, description, shortdesc, iconurl, infourl, joinable, joinerrole, published, publicview,  skin, type)
            print("Creating site {0} was a {1}".format(newsiteid, result))

loginProxy.service.logout(sessionId)


copySite.csv:

gsa_demo,STA200A,STA200A,Elementary Statistics,Elementary Statistics,/library/icon/default.gif,,false,access,true,false,,project
gsa_demo,STA200B,STA200B,Elementary Statistics,Elementary Statistics,/library/icon/default.gif,,false,access,true,false,,project

and here's the Error:

Creating site STA200A was a org.sakaiproject.exception.IdUnusedException : null
Creating site STA200B was a java.lang.NullPointerException : null
Creating site STA200C was a java.lang.NullPointerException : null

 

Thank you for your help

Earle Nietzel

unread,
Aug 12, 2021, 12:56:24 PM8/12/21
to Alaa Nizar, Matthew Jones, Steve Swinsburg, s.swi...@lancaster.ac.uk, Matthew Jones, Sam Ottenhoff, sakai-dev
Hi Alaa,

Can you grab the stack trace from the servers catalina.out log and share it?

-earle

alaanizar

unread,
Aug 12, 2021, 1:03:00 PM8/12/21
to Earle Nietzel, Matthew Jones, Steve Swinsburg, s.swi...@lancaster.ac.uk, Matthew Jones, Sam Ottenhoff, sakai-dev
Hi,
It only give the error that I've sent:
Creating site STA200A was a org.sakaiproject.exception.IdUnusedException : null
Creating site STA200B was a java.lang.NullPointerException : null
Creating site STA200C was a java.lang.NullPointerException : null

Here's the Sakai-Sak that I have found. Sakai 21 is affacte by this sak: 


I switched to 20.4, and the webservice is working fine.

Envoyé depuis mon appareil Galaxy


-------- Message d'origine --------
De : Earle Nietzel <ea...@longsight.com>
Date : 12/08/2021 18:46 (GMT+00:00)
À : Alaa Nizar <alaa...@iihem.ac.ma>
Cc : Matthew Jones <matthe...@learnxp.com>, Steve Swinsburg <steve.s...@gmail.com>, s.swi...@lancaster.ac.uk, Matthew Jones <mat...@longsight.com>, Sam Ottenhoff <otte...@longsight.com>, sakai-dev <saka...@apereo.org>
Objet : Re: BUG in copySite and AddNewSite SAKAI 21 webservice

--
This message has been scanned for viruses and dangerous content

Simo Bougtaibi

unread,
Aug 17, 2021, 6:54:35 AM8/17/21
to Alaa Nizar, sakai-dev, Earle Nietzel, Matthew Jones, Steve Swinsburg, s.swi...@lancaster.ac.uk, Matthew Jones, Sam Ottenhoff
Hi Alla,

Sorry to respond so late i dont have acces to my folders

We have done identity management by external tools like Open AM to enable/desable users to access or not on sakai

For managing acces to sites we use API by adding/remove user to site 

Open AM and user's management access the same database ; then when we desactivate user it is over

we have done this by mixing DNN as user interface for managing , Open AM as security check 
but you can use any other combination like (CAS + Wordpress ) or open AM + Drupal 

i put our document that i hope it can be helpfull

Best regards

--
You received this message because you are subscribed to the Google Groups "Sakai Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sakai-dev+...@apereo.org.


--
Simo.Bougtaibi
Tel : 0762725709
sakai-openam.pptx

alaanizar

unread,
Aug 17, 2021, 7:16:03 AM8/17/21
to Simo Bougtaibi, sakai-dev, Earle Nietzel, Matthew Jones, Steve Swinsburg, s.swi...@lancaster.ac.uk, Matthew Jones, Sam Ottenhoff
Thank you Simo for your email.

I don't want to use another layer. I just wanna know if there a webservice that does this function.

Otherwise I can use the removeMemberFromSite to remove it from all sites, But it's not a clean way to do it.

From the web interface, in Users Tool, there is a check box to disable a given user. I can work with that for the moment.

Thank you bro



Envoyé depuis mon appareil Galaxy


-------- Message d'origine --------
De : Simo Bougtaibi <simo.bo...@gmail.com>
Date : 17/08/2021 12:44 (GMT+00:00)
À : Alaa Nizar <alaa...@iihem.ac.ma>
Cc : sakai-dev <saka...@apereo.org>, Earle Nietzel <ea...@longsight.com>, Matthew Jones <matthe...@learnxp.com>, Steve Swinsburg <steve.s...@gmail.com>, s.swi...@lancaster.ac.uk, Matthew Jones <mat...@longsight.com>, Sam Ottenhoff <otte...@longsight.com>
Objet : Re: [sakai-dev] SAKAI Web service: Activate/Deactivate a user !

Matthew Jones

unread,
Aug 17, 2021, 8:29:28 AM8/17/21
to alaanizar, Simo Bougtaibi, sakai-dev, Earle Nietzel, Steve Swinsburg, s.swi...@lancaster.ac.uk, Matthew Jones, Sam Ottenhoff
Was recently researching this. :Whether or not a user is disabled is just a property. You should be able to use the webservice method setUserProperty to disable the user.

It takes these parameters setUserProperty(sessionid, eid, key, value)

The key is "disabled" value "true". Set to false or clear it to enable the user. 

alaanizar

unread,
Aug 17, 2021, 8:37:25 AM8/17/21
to Matthew Jones, Simo Bougtaibi, sakai-dev, Earle Nietzel, Steve Swinsburg, s.swi...@lancaster.ac.uk, Matthew Jones, Sam Ottenhoff
Thank you Matthew.

Very helpful 



Envoyé depuis mon appareil Galaxy


-------- Message d'origine --------
De : Matthew Jones <matthe...@learnxp.com>
Date : 17/08/2021 14:19 (GMT+00:00)
À : alaanizar <alaa...@iihem.ac.ma>
Cc : Simo Bougtaibi <simo.bo...@gmail.com>, sakai-dev <saka...@apereo.org>, Earle Nietzel <ea...@longsight.com>, Steve Swinsburg <steve.s...@gmail.com>, s.swi...@lancaster.ac.uk, Matthew Jones <mat...@longsight.com>, Sam Ottenhoff <otte...@longsight.com>
Reply all
Reply to author
Forward
0 new messages