Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

Mnet Web services API: Difference between revisions

From MoodleDocs
No edit summary
No edit summary
Line 2: Line 2:


Specifically,
Specifically,
1) Manage user data - send and retrieve the information,
# Manage user data - send and retrieve the information,
2) Manage course enrolments - add/remove teachers and students,
# Manage course enrolments - add/remove teachers and students,
3) Course management - create new courses based on templates,
# Course management - create new courses based on templates,
4) Gradebook info - extract grades information from Moodle.
# Gradebook info - extract grades information from Moodle.


The API will be built in two tiers:
The API will be built in two tiers:
1) Generic Moodle web services - This will define the API available to be used by specific protocols.
# Generic Moodle web services - This will define the API available to be used by specific protocols.
2) Protocol-specific web services - Using the generic services as the parent, define specific interfaces for SOAP, XML-RPC and others.
# Protocol-specific web services - Using the generic services as the parent, define specific interfaces for SOAP, XML-RPC and others.


'''Class Structure:'''
'''Class Structure:'''<br>
Base class <code>server.class.php</code>:
Base class <code>server.class.php</code>:<br>
This class provides most of the necessary functions to authenticate and communicate with Moodle. It also defines the methods that must be implemented by the protocol class. Any web service protocol class must:
This class provides most of the necessary functions to authenticate and communicate with Moodle. It also defines the methods that must be implemented by the protocol class. Any web service protocol class must:
- call the base class constructor (<code>parent::init()</code>),
* call the base class constructor (<code>parent::init()</code>),
- implement the main method (<code>main([$httpdata])</code>),
* implement the main method (<code>main([$httpdata])</code>),
- implement the request method (<code>request($input)</code>),
* implement the request method (<code>request($input)</code>),
- implement the reply method (<code>response($request)</code>).
* implement the reply method (<code>response($request)</code>).


Derived class (e.g. <code>soapserver.class.php</code>).
Derived class (e.g. <code>soapserver.class.php</code>).


The driver for the whole operation is through <code>service.php</code>. It takes one argument, <code>type</code>, which contains a string identifying the protocol to use (e.g. 'soap').
The driver for the whole operation is through <code>service.php</code>. It takes one argument, <code>type</code>, which contains a string identifying the protocol to use (e.g. 'soap').
So, to call a SOAP based web service:
 
So, to call a SOAP based web service:<br>
<code>http://your.server.org/moodle/ws/server.php?type=soap</code>
<code>http://your.server.org/moodle/ws/server.php?type=soap</code>
The data for the entire operation comes through the POST mechanism.
The data for the entire operation comes through the POST mechanism.

Revision as of 19:18, 19 May 2006

Provide Moodle with a web service interface to allow exchange of data and information with other systems.

Specifically,

  1. Manage user data - send and retrieve the information,
  2. Manage course enrolments - add/remove teachers and students,
  3. Course management - create new courses based on templates,
  4. Gradebook info - extract grades information from Moodle.

The API will be built in two tiers:

  1. Generic Moodle web services - This will define the API available to be used by specific protocols.
  2. Protocol-specific web services - Using the generic services as the parent, define specific interfaces for SOAP, XML-RPC and others.

Class Structure:
Base class server.class.php:
This class provides most of the necessary functions to authenticate and communicate with Moodle. It also defines the methods that must be implemented by the protocol class. Any web service protocol class must:

  • call the base class constructor (parent::init()),
  • implement the main method (main([$httpdata])),
  • implement the request method (request($input)),
  • implement the reply method (response($request)).

Derived class (e.g. soapserver.class.php).

The driver for the whole operation is through service.php. It takes one argument, type, which contains a string identifying the protocol to use (e.g. 'soap').

So, to call a SOAP based web service:
http://your.server.org/moodle/ws/server.php?type=soap The data for the entire operation comes through the POST mechanism.


See discussion at

http://moodle.org/mod/forum/discuss.php?d=44079