[Building Sakai] Sakai REST services

Jaco Gillman jaco at opencollab.co.za
Wed Dec 7 01:36:17 PST 2011


Hi All



I would like to make use of the Sakai REST services. I came across
an insightful online slide (
http://www.slideshare.net/steveswinsburg/soap-and-restful-web-services-in-sakai)
that explains the REST usage in Sakai, but I still have some questions.
When I browse to the link "http://sakai.server/direct/announcement/describe"
I can see the announcement decription page on our Sakai deployment. I also
see announcement results when I browse to the following links:

http://sakai.server/direct/announcement/user.json?n=10&d=30

http://sakai.server/direct/announcement/user.json



Now, when I try to invoke this service from a normal html page locally
(return the data in json format), I do not get any results back in the
response, with no errors/exceptions. Is the cross domain to blame here?



*AJAX approach to Sakai REST services implementation:*



                 var url = "
http://sakai.server/direct/announcement/user.json";

                //var url = "
http://sakai.server/direct/announcement/user.json?n=10&d=30";

                  setSakaiOLEConfiguration();

                  new Ajax.Request(url, {

                                  method: 'get',

                                  onSuccess: function(transport) {

                                                var response =
transport.responseJSON || "no response text";

                                                alert("testSakaiWS: " +
response);

                                  },

                                  onException : function(error) {

                                                alert('exception');

                                  },

                                  onFailure : function() {

                                                alert('failure');

                                  }

                });





*Prototype.js lib approach to Sakai REST services implementation:*



    var url = "http://sakai.server/direct/announcement/user.json";

    //var url = "http://sakai.server/direct/announcement/user.json?n=10&d=30
";

    xmlhttp.open('GET',url,true);

    xmlhttp.send(null);

    xmlhttp.onreadystatechange = function() {

         if (xmlhttp.readyState == 4) {

             if ( xmlhttp.status == 200) {

                 alert(xmlhttp.responseJSON);

                //alert(xmlhttp.responseText);

            }

            else

                 alert("Error ->" + xmlhttp.responseText);

        }

     };



Neither one of these approaches (and neither URL values in both examples),
return any values whatsoever.


Regards,

*Jaco Gillman***

Java Developer

opencollab

*Tel*: +27 21 970 4017  |  *Fax*:* *+27 21 914 3098**

*Email*: jaco at opencollab.co.za  |  *Skype*: gillmanjc

*Web*: www.opencollab.co.za
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://collab.sakaiproject.org/pipermail/sakai-dev/attachments/20111207/a3431fe2/attachment.html 


More information about the sakai-dev mailing list