Backoffice tool for testing Web Services

Backoffice tool for testing Web Services

by Alberto del Pozo -
Number of replies: 6
Hi!

First of all sorry for my bad English.

I work for a Spanish enterprise called Clay Formación Internacional (http://www.clayformacion.com/clayweb/home.html) and I have created a backoffice tool (it does some basic actions like manage users, courses, roles, logs, grades, etc. in a simple way) to test Moodle 2.0 web services. This tool is part of my diploma project and it was created to find the needs that the web services layer could have, because this enterprise collaborate with DFWikiLABS, and I work in the Moodle web services project (http://potato.lsi.upc.edu/projects/moodlewebservices).

This tool was created to test the connection with Moodle and find the problems that could appear when creating a client. For this reason it only works with a special Moodle 2.0 version that has some functions added to the external.php files (The Moodle version is from August). These functions added solve some of the problems that were found, such as retrieve all the courses in the platform, all the users in a course and stuff.

It works too with a Moodle 1.9 that uses the same web services but backported to this version. It can connect with Moodle using XML-RPC and SOAp protocols, but have some problems when connecting via REST.

In addition to this, it was added a java applet that connect with Moodle via XML-RPC. This applet is part of a visualization tool (created by Diego Alonso Gómez) which is still a beta, but proves that a java tool can connect via web services with Moodle.

I share it just in case it could be useful for the web services development, and if somebody is interested in it I will update the code of the tool and the two Moodles necessaries to test it (Moodle 2.0 and Moodle 1.9).

The next step is to connect with new Moodle versions, due to there have been many changes in the way to connect and also it's necessary to add some functions to the externallib.php files for it to work.

Finally, there is an image of the tool attached with the post.


Cheers.
Pozo.
Attachment List_of_enrolments.jpg
Average of ratings: -
In reply to Alberto del Pozo

Re: Backoffice tool for testing Web Services

by Daniel Cruz -
There is anyway that i can test that?

Thanks.
In reply to Daniel Cruz

Re: Backoffice tool for testing Web Services

by Alberto del Pozo -
Hi Daniel

Right now I'm working in order to connect this tool via REST with a Moodle version downloaded yesterday. I think next week I'll have managed to do this, so the code I will upload will only be some KB because (I think) you will be able to test it with a moodle you can download here, adding only some externallib.php files more.

If you want to test the current tool version I'll have to send you about 60 MB (two fully moodles), so maybe you prefer waiting

Thanks for being interested.

Cheers.
Pozo.
In reply to Daniel Cruz

Re: Backoffice tool for testing Web Services

by Alberto del Pozo -
Hi!

I have changed the tool in order to work with newest moodle version. I have just tested it with a today moodle version and it works. By now, I can only manage to connect via xmlrpc because I've some problems parsing the xml data that REST connector gives back (I've tried with simplexml and DOM functions, but I don't get the data how I want).

In this post and in the next three I attach the code of the web services that needs to be added to moodle and the tool. If anybody know how I can attach more than 100 kb per post please tell me.

Now the steps that need to be followed to use the web services:

- Download and install today moodle version
- Create a user with username=wsuser and password=wspassword (need to to this directly in the DB, using md5).
- Give wsuser the administrator rol
- Run the moodle20/webservice/functions.php script that inserts all the ws functions in the mdl_external_functions table in the DB
- Enable web services with all the steps that appears in plugin->webservices->overview (add all the functions to the service created, although most of them are not going to be used)
- Enable web service authentication and turn debug display off



Now copy the tool folder in the localhost folder (if changed the location or the name of the folder you need to edit config.php file) and it should work correctly

The only problem is that I've haven't found how to get the user token, so all the connections are done sending username and password, so if there is some fail when logging in to the tool, all the tool is going to fail because It won't have saved the data

Finally, the externallib.php can be found in the DFWikiLABS repository, in the moodle web services project, although for using this tool I've added some functions that were necessary but are not in the repository.

Cheers.
Pozo.