<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
	<id>http://wiki.mipt.ru/index.php?action=history&amp;feed=atom&amp;title=Development%3ACreating_a_web_service_client</id>
	<title>Development:Creating a web service client - История изменений</title>
	<link rel="self" type="application/atom+xml" href="http://wiki.mipt.ru/index.php?action=history&amp;feed=atom&amp;title=Development%3ACreating_a_web_service_client"/>
	<link rel="alternate" type="text/html" href="http://wiki.mipt.ru/index.php?title=Development:Creating_a_web_service_client&amp;action=history"/>
	<updated>2026-05-06T17:34:30Z</updated>
	<subtitle>История изменений этой страницы в вики</subtitle>
	<generator>MediaWiki 1.42.1</generator>
	<entry>
		<id>http://wiki.mipt.ru/index.php?title=Development:Creating_a_web_service_client&amp;diff=10972&amp;oldid=prev</id>
		<title>Олег Давидович: 1 версия импортирована</title>
		<link rel="alternate" type="text/html" href="http://wiki.mipt.ru/index.php?title=Development:Creating_a_web_service_client&amp;diff=10972&amp;oldid=prev"/>
		<updated>2024-10-21T08:51:07Z</updated>

		<summary type="html">&lt;p&gt;1 версия импортирована&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Предыдущая версия&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Версия от 08:51, 21 октября 2024&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Олег Давидович</name></author>
	</entry>
	<entry>
		<id>http://wiki.mipt.ru/index.php?title=Development:Creating_a_web_service_client&amp;diff=10971&amp;oldid=prev</id>
		<title>1&gt;Ibakayoko: /* XML-RPC */</title>
		<link rel="alternate" type="text/html" href="http://wiki.mipt.ru/index.php?title=Development:Creating_a_web_service_client&amp;diff=10971&amp;oldid=prev"/>
		<updated>2011-04-22T14:42:33Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;XML-RPC&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Moodle_2.0}}&lt;br /&gt;
[[Image:Moodle web service function documentation.jpg|thumb]]You need to have already setup a web service. You can get help from [[How to enable web services for ordinary users]] or [[How to enable web services for an external system]] . Then have a look to your [https://docs.moodle.org/en/How_to_get_a_security_key security keys] page. You&amp;#039;ll find there your token and the web service documentation associated with this token.&lt;br /&gt;
&lt;br /&gt;
= Officially supported protocols=&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;REST&amp;#039;&amp;#039;&amp;#039;: the Moodle REST server uses POST for parameters and XML for returned values. This server is not RESTfull.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;SOAP&amp;#039;&amp;#039;&amp;#039;: the Moodle SOAP server is based on the Zend SOAP server (itself based on the PHP SOAP server). Zend publishes [http://framework.zend.com/manual/en/zend.soap.client.html a Zend SOAP client]. The current server implementation doesn&amp;#039;t work with Java/.Net because we didn&amp;#039;t generated [http://geekandpoke.typepad.com/geekandpoke/2009/11/service-calling-made-easy-part-1.html a fully describe WSDL] yet. If you are working on a Java/.Net client, follow or participate to the tracker issue MDL-20804&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;XML-RPC&amp;#039;&amp;#039;&amp;#039;: the Moodle XML-RPC server is based on Zend XML-RPC server. Zend also publishes [http://framework.zend.com/manual/en/zend.xmlrpc.client.html a Zend XML-RPC client].&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;AMF&amp;#039;&amp;#039;&amp;#039;: the Moodle AMF server is based on the Zend AMF server. The test client can be found in &amp;#039;&amp;#039;Settings blocks &amp;gt; Site Administration &amp;gt; Development &amp;gt; Web service test client &amp;gt; AMF Test client&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
= PHP client examples =&lt;br /&gt;
In all these client examples we will create two groups calling the web service function &amp;#039;&amp;#039;moodle_group_create_groups&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
== XML-RPC ==&lt;br /&gt;
The Moodle XML-RPC server extends Zend XML-RPC Server. It is recommended to have a look to the [http://framework.zend.com/manual/en/zend.xmlrpc.client.html Zend XML-RPC client documentation]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&lt;br /&gt;
include &amp;#039;Zend/Loader/Autoloader.php&amp;#039;;&lt;br /&gt;
Zend_Loader_Autoloader::autoload(&amp;#039;Zend_Loader&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
$function = &amp;quot;moodle_user_get_users_by_id&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
// id of the users&lt;br /&gt;
$params = array(array(2,4));&lt;br /&gt;
&lt;br /&gt;
$serverurl = &amp;quot;http://{servername}/webservice/xmlrpc/server.php?wstoken=$token&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
$client = new Zend_XmlRpc_Client($serverurl);&lt;br /&gt;
print &amp;quot;&amp;lt;pre&amp;gt;&amp;quot;;&lt;br /&gt;
try {&lt;br /&gt;
    $data = $client-&amp;gt;call($function, $params);&lt;br /&gt;
    var_dump ($data);&lt;br /&gt;
} catch (exception $exception) {&lt;br /&gt;
    var_dump ($exception);&lt;br /&gt;
}&lt;br /&gt;
print &amp;quot;&amp;lt;/pre&amp;gt;&amp;quot;;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== SOAP ==&lt;br /&gt;
The Moodle SOAP server extends Zend SOAP Server. It is recommended to have a look to the [http://framework.zend.com/manual/en/zend.soap.client.html Zend SOAP client documentation].&lt;br /&gt;
Except the class name &amp;#039;&amp;#039;Zend_Soap_Client&amp;#039;&amp;#039;, the entire example code would be similar to XML-RPC.&lt;br /&gt;
&lt;br /&gt;
== REST ==&lt;br /&gt;
Look at the web service function documentation on your [https://docs.moodle.org/en/How_to_get_a_security_key security keys] page to know about the returned XML structure.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
//get the profile data of Moodle User&lt;br /&gt;
&lt;br /&gt;
include &amp;#039;Zend/Loader/Autoloader.php&amp;#039;;&lt;br /&gt;
Zend_Loader_Autoloader::autoload(&amp;#039;Zend_Loader&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
$params = array(&lt;br /&gt;
    &amp;#039;userids&amp;#039; =&amp;gt; array(2,4), // the params to passed to the function&lt;br /&gt;
    &amp;#039;wsfunction&amp;#039; =&amp;gt; &amp;#039;moodle_user_get_users_by_id&amp;#039;,   // the function to be called&lt;br /&gt;
    &amp;#039;wstoken&amp;#039; =&amp;gt; &amp;#039;8dc8f5ca046129706c0d85a56efcaddd&amp;#039; //token need to be passed in the url&lt;br /&gt;
);&lt;br /&gt;
&lt;br /&gt;
//set web service url server&lt;br /&gt;
$serverurl = &amp;quot;http://{servername}/webservice/rest/server.php&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
$client = new Zend_Http_Client($serverurl);&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;&amp;lt;pre&amp;gt;&amp;quot;;&lt;br /&gt;
try {&lt;br /&gt;
    $client-&amp;gt;setParameterPost($params);    &lt;br /&gt;
    $response = $client-&amp;gt;request(&amp;#039;POST&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
    var_dump ($response);&lt;br /&gt;
} catch (exception $exception) {&lt;br /&gt;
    var_dump ($exception);&lt;br /&gt;
}&lt;br /&gt;
print &amp;quot;&amp;lt;/pre&amp;gt;&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Web Services]]&lt;/div&gt;</summary>
		<author><name>1&gt;Ibakayoko</name></author>
	</entry>
</feed>