Web Services Documentation

Comment below with ideas for cool/useful things you want to do with Sakai Web Services!

A Definition from Wikipedia:

A web service is a collection of protocols and standards used for exchanging data between applications. Software applications written in various programming languages and running on various platforms can use web services to exchange data over computer networks like the Internet, in a manner similar to inter-process communication on a single computer. This interoperability (eg. between Java and Python, or Windows and GNU Linux applications) is due to the use of open standards. OASIS and the W3C
http://en.wikipedia.org/wiki/Web_service

Web Services in Sakai

Support for Web Services was added in Sakai 2.0 chiefly by integrating Apache Axis into the code base. There are a couple of strategies you can use to expose web services from inside Sakai.

You can build WSDL descriptions and...
?? I think Samigo is building WSDL and other things ??

Another option for exposing methods to Web Services is by creating Java methods in a file with a *.jws extension and placing it in the webapps/sakai-axis directory. There are some examples there. Using this method you don't need to generate any of the SOAP XML yourself, the method signatures are automatically translated by Axis.

More information is available in:

Steve Githens' Web Services

HTTP vs HTTPS in Using Web Services - Former user (Deleted)

I was having difficulties connecting to the SakaiLogin.jws?wsdl file. I was trying to connect through Perl and using the SOAP::Lite module.

This simple fragment of code should have worked:

use SOAP::Lite;

my $user = 'admin';
my $password = 'admin';

my $loginURI = "https://myserver/sakai-axis/SakaiLogin.jws?wsdl";
my $loginsoap = SOAP::Lite
-> proxy($loginURI)
-> uri($loginURI);

my $session = $loginsoap->login($user, $password)->result;
print "$session\n";

But I was getting a 500 Connect failed: connect: Connection refused; error.

At first I thought it might have been the self-signed certificate that we are using whilst we integrate, so we put in the certificate environment variables into the script as per the SOAP::Lite documentation so that the certificate and key could be found:

use SOAP::Lite;

$ENV{'HTTPS_CERT_FILE'} = '/path/to/my/server/certificate.crt';
$ENV{'HTTPS_KEY_FILE'}  = '/math/to/my/server/key.key';

....

but still no luck. Same error.

Note re adding the environment variables

Since we are writing a script to connect to a web service, there is the possibility of having the script on a different machine altogether, but this would be restricted by having the environment variables hard coded into your script, so you should use a more flexible method of connecting over HTTPS to the web service provider.

Also, the certificate and key must be readable by the user executing the script that requires them otherwise you will get an errr saying they cannot be read. Allowing read access to the certificate and key might be an issue of security for you.

We then disabled SSL on the server and tried again, this time with the URL being HTTP instead of HTTPS, but this time I get a 404 Not Found error! The file clearly exists, I can browse to it and get the WSDL XML displayed on screen.

That got me thinking and finally I came up with...

The solution

We have our server setup so that Apache hands off the requests to Tomcat that it needs to, with Apache running on the standard port 80 and Tomcat running on port 8080. When browsing via the web, I access Sakai through port 80, but under the hood, Apache is handing off the requests to Tomcat and connecting through port 8080. Because I wasn't going through Apache with this Perl script, I needed to add the port to the URL to connect directly through Tomcat so the URL becomes: http://myserver:8080/sakai-axis/SakaiLogin.jws?wsdl

After I did that, the requests went through fine. Now to turn SSL back on (smile)