Note:

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

Web services: Difference between revisions

From MoodleDocs
(Cleaned up and added an actual listing of our web services!)
Line 2: Line 2:


==Introduction==
==Introduction==
This page described the Web Services module implemented for Moodle 2.0<br>
This page describes the Web Services implementation that was added to Moodle 2.0 and is being extended with every subsequent version.
The official discussion [http://moodle.org/mod/forum/view.php?id=6971| forum is here]<br>
 
The tracker issues are here: MDL-12886 and MDL-17135<br>
We support multiple web service protocols (REST, SOAP, XML-RPC and AMF). If that's not enough, support for new protocols can be added easily.
This module is been implemented by Moodle HQ and [http://blogs.dfwikilabs.org/moodle_ws/ DFWS Team].


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 ==
== How it works ==
This following example would work 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.
This simple example will give you an idea of how our web services infrastructure works. See [[External services security]] for more details.
#The client sends a username and password to the web service protocol server script.
#The client sends a username and password to the web service protocol server script.
#The protocol server returns a session token for that user account (how this is sent depends on the protocol).
#The protocol server returns a session token for that user account (how this is sent depends on the protocol).
Line 24: Line 22:
==Web description format==
==Web description format==


All functions that can be called via web services can be declared in a db/service.php file and can be defined in an externallib.php file somewhere. The description of the functions that can be called, and what parameters they require, are explained in the [https://docs.moodle.org/en/Development:Web_services_description External Service description document].
All functions that can be called via web services are declared in a db/service.php file and can be defined in an externallib.php file somewhere. The classes we use to define these functions are explained in the [https://docs.moodle.org/en/Development:Web_services_description External Service description document].
 
==Web services functions==
 
Every Moodle sites can provide you with a page listing all function descriptions, with useful advice for any supported protocol.  


==Web services technical documentation==
To call this page: ''your_moodle/webservice/wsdoc.php?protocol=soap
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
''
''
However, here is a list of the functions available in Moodle 2.1:
user:
* create_users()
* delete_users()
* update_users()
* get_users_by_id()
* get_course_participants_by_id()
* get_users_by_courseid()
course:
* get_courses()
* create_courses()
group:
* create_groups()
* get_groups()
* get_course_groups()
* delete_groups()
* get_groupmembers()
* add_groupmembers()
* delete_groupmembers()
enrol:
* get_enrolled_users()
* get_users_courses()
* role_assign()
* role_unassign()
enrol/manual:
* manual_enrol_users()
webservice:
* get_siteinfo_parameters()
message:
* send_instantmessages()
files:
* get_files()
* upload()


==Authentication==
==Authentication==
Please have a look to the [[External services security]] page
Please have a look to the [[External services security]] page
==See also==
==See also==
* The official discussion [http://moodle.org/mod/forum/view.php?id=6971| forum is here]
* The tracker issues are here: MDL-12886 and MDL-17135
* [[External services security]]
* [[External services security]]
* [[External services description]]
* [[External services description]]

Revision as of 09:04, 8 August 2011

Moodle 2.0


Introduction

This page describes the Web Services implementation that was added to Moodle 2.0 and is being extended with every subsequent version.

We support multiple web service protocols (REST, SOAP, XML-RPC and AMF). If that's not enough, support for new protocols can be added easily.


How it works

This simple example will give you an idea of how our web services infrastructure works. See External services security 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 are declared in a db/service.php file and can be defined in an externallib.php file somewhere. The classes we use to define these functions are explained in the External Service description document.

Web services functions

Every Moodle sites can provide you with a page listing all function descriptions, with useful advice for any supported protocol.

To call this page: your_moodle/webservice/wsdoc.php?protocol=soap

However, here is a list of the functions available in Moodle 2.1:

user:

  • create_users()
  • delete_users()
  • update_users()
  • get_users_by_id()
  • get_course_participants_by_id()
  • get_users_by_courseid()

course:

  • get_courses()
  • create_courses()

group:

  • create_groups()
  • get_groups()
  • get_course_groups()
  • delete_groups()
  • get_groupmembers()
  • add_groupmembers()
  • delete_groupmembers()

enrol:

  • get_enrolled_users()
  • get_users_courses()
  • role_assign()
  • role_unassign()

enrol/manual:

  • manual_enrol_users()

webservice:

  • get_siteinfo_parameters()

message:

  • send_instantmessages()

files:

  • get_files()
  • upload()


Authentication

Please have a look to the External services security page

See also