Note:

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

Web services

From MoodleDocs
Revision as of 01:58, 13 October 2009 by jerome mouneyrac (talk | contribs)

Moodle 2.0


Introduction

This page described the Web Services module implemented for Moodle 2.0
The official discussion forum is here
The tracker issue is here: MDL-12886
This module is been implemented by Moodle HQ and DFWS Team.

The Web Services module has been conceived in order to be ported to different Moodle versions and for different projects. The objective is to support multiple web service protocols (REST, SOAP, XML-RPC and AMF). Adding support for a new protocol should be relatively easy.

How it works

This following example works but it will not be the unique way to access web services. Please have a look to the External services security page for more details.

  1. The client sends a username and password to the web service protocol server script.
  2. The protocol server returns a session token for that user account (how this is sent depends on the protocol).
  3. The client calls a particular web service function including the session token.
  4. The protocol server uses the token to check that the web service session is still active.
  5. The protocol server call the matching external function, located in a externallib.php file inside the relevant module.
  6. The external function checks that the current user has_capability to do this operation.
  7. The external function calls the matching Moodle core function (in lib.php usually).
  8. The core function can return a result to the external function.
  9. The external function will return a result to the protocol server.
  10. The protocol server returns the result to the client.

Web description format

All functions that can be called via web services can be declared in an externallib.php file somewhere. The description of the functions that can be called, and what parameters they require, is defined in the Service description page.

Web services technical documentation

In order to facilitate a Moodle web service client implementation, every Moodle sites will provide a page listing all function descriptions. This page also gives some useful advice for any supported protocol. To call this page: your_moodle/webservice/wsdoc.php?protocol=soap

Authentication

Please have a look to the External services security page

See also