Updated Java Library REST Protocol

Updated Java Library REST Protocol

by Bill Antonia -
Number of replies: 15

For those who have downloaded previous versions and anyone else interested..........

Java library for access to Moodle's web services via the REST protocol

(29/03/2012) A newer version (V0.1.4) to work with Moodle 2.2 has been uploaded. Although still requires more documentation (better than it was) etc... Calls to create and update users now provides facilities to add preferences and customfields. Removed the batch calling of the web services (not needed as all calls are via POST and not GET), code is still there but commented out. Calls to both newer core and moodle webservices functions can be called, the latter requires a legacy switch to be set.

Previous versions using the Moodle 2.1 webservice calls are still there.

http://sourceforge.net/projects/moodlerestjava/files/V0.1.4/

Note Library is "alpha" so please test before you use in anger!

Both the Library as a .jar file and a complete zipped NetBeans project folder is there with sources.

Any modifications you do please let me know so they may be added.

Average of ratings: -
In reply to Bill Antonia

Re: Updated Java Library REST Protocol

by Bill Antonia -

Whoops! Found a few issues, fixing them now. Will upload to sourceforge after fixed.

In reply to Bill Antonia

Re: Updated Java Library REST Protocol

by Bill Antonia -

Sorted the bugs, well most I could find anyway. Removed V0.1.4 and created V0.1.5

http://sourceforge.net/projects/moodlerestjava/files/V0.1.5/

There are also some examples which you will have to modify to suit your Moodle server. NetBeans projects.

As I said earlier, please test somewhere no damage can occur first before use in a live system.

Average of ratings: Useful (1)
In reply to Bill Antonia

Re: Updated Java Library REST Protocol

by Jérôme Mouneyrac -
In reply to Jérôme Mouneyrac

Re: Updated Java Library REST Protocol

by Bill Antonia -

Something I now have to keep up to date and plan ahead for 2.3!

Where do I go to find the order, proposed function names and datastructures for future releases?

In reply to Bill Antonia

Re: Updated Java Library REST Protocol

by Jérôme Mouneyrac -
Hi Bill, I thought it would be good for other Java devs to know about it. If you don't have time to keep the library up to date, it's totally understandable. I saw that like a quick starter code. You can mention it in the Moodledocs smile
In reply to Jérôme Mouneyrac

Re: Updated Java Library REST Protocol

by Bill Antonia -

Not a problem, I'll keep it up to date as much as possible. I'm thinking of keeping a copy of the work in progress on a server out on the Internet which I use for running various websites.

Looking at the Roadmap, I'm interested in particular with the webservices which deal with grades so I can transparently transfer attaiment data into our MIS (SIMS) at some point, after hopefully I'm given access to their "Business Objects".

In reply to Bill Antonia

Re: Updated Java Library REST Protocol

by Patrick Pollet -

Your life will become easier when Moodle WS will generate a real WSDL as requested in http://tracker.moodle.org/browse/MDL-28989  (Jérome si tu m'entends ? wink )  in that case generation of your REST client library will be handled by a simple re-parsing of the updated WSDL and automatic classes generation by some XSLT rewriting tools similar to what  wsdl2java  does for SOAP protocol. 

See https://github.com/patrickpollet/moodlews_gson for java classes automatically generated by such tools for OK Tech WS in REST mode. 

Cheers 

Average of ratings: Useful (1)
In reply to Patrick Pollet

Re: Updated Java Library REST Protocol

by Bill Antonia -

Until that day.....................................................................

Is anyone currently working on a solution?

In reply to Bill Antonia

Re: Updated Java Library REST Protocol

by Jérôme Mouneyrac -
I don't think anyone is currently working on it.
In reply to Jérôme Mouneyrac

Re: Updated Java Library REST Protocol

by Bill Antonia -

Ok, I'll keep working on the library.

I'm currently coding classes to access the functions which are in the tracker, particularly the ones marked as "Waiting for peer review" or "Waiting for integration review". Is there anywhere I can get hold of any example output from these functions?

I've written some classes but I am coding blind regarding parsing the XML output. Most of the time the output has <RESPONSE>....</RESPONSE> tags, but not always. Generally other tags follow the array name, but I'm guessing at the moment.

The last one coded for was mod_assign_get_submissions, that one was quite complex in terms of data structure!

In reply to Bill Antonia

Re: Updated Java Library REST Protocol

by Jérôme Mouneyrac -
Hi Bill, if you cherry-pick a in-progress function (note that the code could change), you can get the REST response structure from Admin settings > Plugins > Web services > API Documentation Cheers, Jerome
In reply to Jérôme Mouneyrac

Re: Updated Java Library REST Protocol

by Bill Antonia -

Hi Jerome,

The only problem is that the new calls for 2.3 are not documented there yet. I have downloaded and installed a 2.3 version to use for testing purposes but the list is still 2.2.

In reply to Bill Antonia

Re: Updated Java Library REST Protocol

by Jérôme Mouneyrac -
Hi Bill, at this time, none of the new 2.3 web service functions are integrated into the unstable branch (master). It's why you don't see them in the API documentation, they are not in master. They are in each developer repository, but if I were you I would wait for them to land into master. Cheers, Jerome
In reply to Bill Antonia

Re: Updated Java Library REST Protocol

by Bill Antonia -
Version 0.1.6 is almost ready, just a few calls more to do then go through testing. The current code is can be downloaded from https://github.com/bantonia/MoodleRest This version is able to use the calls in Moodle 2.6. There is one SOAP call as far as I can tell which is not in the REST call list. There are also some issues in Moodle web services which will give errors, you have to edit the Moodle code to get them to work.