Web services API: Difference between revisions
From MoodleDocs
Line 5: | Line 5: | ||
Once you have done this, your functions will be available to admins to configure as part of their Web services over a given protocol like XML-RPC, REST or SOAP. | Once you have done this, your functions will be available to admins to configure as part of their Web services over a given protocol like XML-RPC, REST or SOAP. | ||
You must create two files to expose web service functions: | |||
* plugin/db/services.php - the declaration of your web service functions | |||
* plugin/externallib.php - the functions implementation | |||
== services.php == | |||
* This file is located in the db folder of your plugin | |||
* It contains an array contains declaring your web service functions. Each of these declarations reference an external function. | |||
== externallib.php == | |||
* This file is located at the root of your plugin. | |||
* This file is composed by a class that contains the external function referenced in services.php | |||
== Example == | |||
Have a look to the [https://github.com/moodlehq/moodle-local_wstemplate web service template]. It is a simple hello_world function. It also contains a test client in the folder /client. | |||
==See also== | ==See also== | ||
* [[Core APIs]] | * [[Core APIs]] |
Revision as of 03:55, 12 January 2012
Overview
The Web services API allows you to expose particular functions in your module (usually external functions) as web services.
Once you have done this, your functions will be available to admins to configure as part of their Web services over a given protocol like XML-RPC, REST or SOAP.
You must create two files to expose web service functions:
- plugin/db/services.php - the declaration of your web service functions
- plugin/externallib.php - the functions implementation
services.php
- This file is located in the db folder of your plugin
- It contains an array contains declaring your web service functions. Each of these declarations reference an external function.
externallib.php
- This file is located at the root of your plugin.
- This file is composed by a class that contains the external function referenced in services.php
Example
Have a look to the web service template. It is a simple hello_world function. It also contains a test client in the folder /client.