[Building Sakai] PERL SOAP on Windows Gotchas

Jon Wheat jwheat at messiah.edu
Wed Sep 9 07:28:46 PDT 2009


I just posted this comment to Steve's Sakai Web services gotchas page.
Just a couple items I've hit when dealing with ActivePerl on Windows - probably nothing you Mac people have ever dealt with ;-)
 
<<< BEGIN >>>
I'd like to post a couple 'ActivePerl on Windows' Gotchas.  These may also apply to Linux / Mac - I have no idea.

Now that I've found the SOAP calls, I love them and write scripts to manage Sakai all the time from my desktop machine.  We have Sakai on Linux, but my desktop is Windows with ActivePerl installed and I've run into some interesting things that may be related to newbie-isms, but I'll share them in hopes they help someone else.Getting (the right) Return Results
When you perform a SOAP call in PERL using the ActivePerl  SOAP::Lite module you need to know that if the SOAP call is successful, it will return a 1.  If the SOAP call fails, it will return a 1. This can be misleading / confusing / frustrating :
if you're expecting a result from a SOAP call and continue to get a 1 only. 
and nothing is happening in Sakai (the function call is actually failing or not getting called at all)

This 1 is simply the fact that PERL called soap and the call was executed period. It is NOT the result of the function call that Sakai is sending back. 

When you want a result from a webservice SOAP call you need to add ->result to the end of the call and set a variable for it like this : $siteExists = $scriptsoap->checkForSite($session, $newsiteid)->result;

Now you can print that to the screen or use it later in your script like this :
         if ($siteExists eq 1) {            print "+> Skipping Creation of $newsiteid - Already Exists\n";        } else {             print "+> Creating site \"$title\" \n ";                    my $resultcode = $scriptsoap->addNewSite($session, $newsiteid, $title,$desc_long,$title,"","",$false,"Student",$false,$false,"","course")->result;                         if ($resultcode ne "success") {                print "+> -FAILED : $resultcode\n";            }        }

Proper SOAP Parameters
If you execute your script and are seeing this error -
 Use of uninitialized value in string eq at scriptname.pl line 74.
This can be an incredibly frustrating error - because it doesn't tell you how you screwed up. When seeing this error, check your SOAP function call.  Compare the number (and type) of parameters you're sending to that listed in your SakaiScript.jws file (located in src_dir/webservices/axis/src/webapp).  This is a text file that holds the JAVA code for the SOAP functions -most of which you can find on Steve's page ( http://confluence.sakaiproject.org/display/~steve.swinsburg/Additional+web+services+for+Sakai )

Make sure - if there are 3 parameters in SakaiScript.jws that you're sending 3.  If they're strings, or boolean, make sure you're sending a string or a boolean. Also make sure the values of the variables you're using are what you think they are. Print them to the screen if you have to.  If you mistype a variable name or cut and paste someone else's code, variable names may be similar but wrong (and undefined - ie. $session / $sessionid )
The bottom line with this error is that you have something wrong in your code, even though it may look correct at first glance. 
-Jon
 
<<<END>>>
 Source : 
[ http://confluence.sakaiproject.org/display/~steve.swinsburg/Sakai+web+service+gotchas?focusedCommentId=65867662&#comment-65867662 ( http://confluence.sakaiproject.org/display/~steve.swinsburg/Sakai+web+service+gotchas?focusedCommentId=65867662&#comment-65867662 ) ]
 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://collab.sakaiproject.org/pipermail/sakai-dev/attachments/20090909/c2a10028/attachment.html 


More information about the sakai-dev mailing list