1 This is my version of Web Services for Moodle, based on "OK Technologies 1.4 alpha
2 version":http://moodle.org/mod/data/view.php?d=13&rid=573
4 For discussions see "Moodle developper forum":http://moodle.org/mod/forum/discuss.php?d=67947
6 Latest releases, documentations and (hopefully more) on this page
7 http://cipcnet.insa-lyon.fr/Members/ppollet/public/moodlews/
11 In current 1.5.x version, Moodle server MUST be running on php5 with soap support. ( php5/nusoap support is
12 planned soon by re-injecting code from version 1.4). php4 support is less obvious ...
17 1 unpack "this archive":http://cipcnet.insa-lyon.fr/Members/ppollet/public/moodlews/latest-version/ in your
20 2 may be limit access to this directory to some trusted machines by a well crafted .htaccess file ;-)
22 3 MUST DO : Make sure the WSDL file (that describes the offered services ) is accessible by calling in a
23 browser 'http://yourmoodle/wspp/wsdl_pp.php ' . It should present you a file (moodlews.wsdl) to download. You
24 may cancel the operation since this file is not needed. It that fails, check the Apache error logs for reason of
27 - incorrect location of wspp directory (file not found)
29 - htaccess too restrictive
31 - PHP parse error when parsing wsdl_pp.php ( bad php version or required classes or libraries not
39 PHP5 clients with built-in SoapClient (extension php_soap installed) :
41 go to clients directory, edit and rename auth.php.dist to auth.php
42 file to give a valid user/password (known to Moodle AND having auth method as 'manual' or 'email')
44 MUST DO :check & run once the script ./mkclasses.sh to generate an appropriate client side MoodleWS file
45 or run php ../wsdl2php.php http://yourmoodle/wspp/wsdl_pp.php
47 try the scripts either in command line or via http://
49 pp1.php : try some API calls. Values of user's names, ids, idnumbers ...may need to be adapted to your
52 ws_xls_course.php return a CSV file of users having a given role
54 eg: php ws_xls_course.php 2 5 (all students of course 2)
55 or http://yourmoodle/wspp/clients/ws_course_xls.php?courseid=2&roleid=5
57 - for remote access, copy wspp/wsdl2php.php to your workstations and run it by
58 'php wsdl2php.php http://yourmoodle/wspp/wsdl_pp.php'
59 This will generate the MoodleWS.php with correct URI and the type classes
60 needed by your PHP5 clients. (see clients directory)
61 - alternatively, copy the complete clients directory (after having ran once the test suite )
62 somewhere on a client workstation and use the demo suite scripts as a starting point.
65 PHP5 clients without php_soap extension :
67 go to clients directory, edit and rename auth.php.dist to auth.php
68 file to give a valid user/password (known to Moodle AND having auth method as 'manual' or 'email')
70 MUST DO :check & run once the script ./mkclasses.sh with extra parameter 'nusoap' to generate an
71 appropriate client side MoodleWS_NS.php file
72 or run 'php ../wsdl2php.php http://yourmoodle/wspp/wsdl_pp.php nusoap' (note the extra parameter)
73 This will generate an appropriate MoodleWS_NS.php file to include in your clients.
75 see clients/ws_xls_course_nusoap.php as an example ...Please read the caveats at the top of the script
76 (different syntax to access result's members and memory issue ).
80 see clients/ws-test.php that uses (a copy of ) Moodle supplied nusoap library in lib/nusoap.lib
81 (so just copy this library to your remote clients ).
85 Basic testing :make sure you have SOAPPy installed.
86 see clients/ws-test.py
88 More sophisticated use : install ZSI and use wsdl2py utility.
93 You must have Apache Axis (tested with 1.4 dated April 2006) .
94 See clients/Test1.java
98 User provided to the login function MUST exist (of course) AND have its authentication
99 method set to manual or email .LDAP may work (untested), but not CAS !
102 Extending operations :
104 Save current wspp directory somewhere ...
106 You must add new entries in the wsdl_pp.php script in the appropriate XML sections to describe datatypes
107 (input & output), messages, ports and operations.
109 Then add the basic call in the class server.class.php (with the proper calls to Moodle's API functions to
110 test for rights, fetch the data and eventually filtering it)
112 Add the protocol specific call in mdl_soapserver.php. Code is almost always the same and could be generated
113 by a copy/paste of an existing method. NO Moodle'API call should be there !
115 MUST DO: run the script wspp/mkclasses.sh or run php wsdl2php.php http://yourmoodle/wspp/wsdl_pp.php server
116 (note the extra parameter server). This will generate a new file MoodleWS.php that includes all classes
117 declarations (and base constructors) for existing and new data types.
119 Test , retest and reretest at the command line from wspp/clients directory by :
121 - rerunning the script wspp/clients/mkclasses.sh at EVERY change to the wspp/wsdl_pp.php file
123 - add the call to your new operation to one of the test scripts (e.g. ppdemo.php for PHP5 with
124 php_soap or ws-test.php for PHP5 without php_soap )
126 When Ok, do not forget to update your remote clients by running on each of them wsdl2php for PHP5 clients
127 (with or without nusoap second parameter), wsdl2py for Python clients or WSLD2java for Java clients ...
132 - Justin Filip @ OK Technologies for the 1.4 version
134 - Catalin Maican for many tests with Visual Studio 2005.
136 - Knut Urdalen for version 0.2 of wsld2php
138 - Apache foundation for Axis package & WSDL2Java
140 - Zolera Systems, Inc. for Z.I.S. Python library
142 - Moodle's team for a clean Moodle API
151 Patrick POLLET <patrick.pollet@insa-lyon.fr>