Commit 82e1b645 authored by David Monllaó's avatar David Monllaó

Merge branch 'MDL-52208-master-2' of git://github.com/junpataleta/moodle

parents b018aec5 79c7fffc
This diff is collapsed.
This diff is collapsed.
......@@ -14,7 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Moodle SOAP library
*
......@@ -23,8 +22,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once 'Zend/Soap/Client.php';
/**
* Moodle SOAP client
*
......@@ -34,11 +31,17 @@ require_once 'Zend/Soap/Client.php';
* @copyright 2010 Jerome Mouneyrac
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class webservice_soap_client extends Zend_Soap_Client {
class webservice_soap_client {
/** @var string server url e.g. https://yyyyy.com/server.php */
/** @var moodle_url The server url. */
private $serverurl;
/** @var string The WS token. */
private $token;
/** @var array|null SOAP options. */
private $options;
/**
* Constructor
*
......@@ -46,10 +49,10 @@ class webservice_soap_client extends Zend_Soap_Client {
* @param string $token the token used to do the web service call
* @param array $options PHP SOAP client options - see php.net
*/
public function __construct($serverurl, $token, $options = null) {
$this->serverurl = $serverurl;
$wsdl = $serverurl . "?wstoken=" . $token . '&wsdl=1';
parent::__construct($wsdl, $options);
public function __construct($serverurl, $token = null, array $options = null) {
$this->serverurl = new moodle_url($serverurl);
$this->token = $token ?: $this->serverurl->get_param('wstoken');
$this->options = $options ?: array();
}
/**
......@@ -58,8 +61,7 @@ class webservice_soap_client extends Zend_Soap_Client {
* @param string $token the token used to do the web service call
*/
public function set_token($token) {
$wsdl = $this->serverurl . "?wstoken=" . $token . '&wsdl=1';
$this->setWsdl($wsdl);
$this->token = $token;
}
/**
......@@ -70,15 +72,22 @@ class webservice_soap_client extends Zend_Soap_Client {
* @return mixed
*/
public function call($functionname, $params) {
global $DB, $CFG;
if ($this->token) {
$this->serverurl->param('wstoken', $this->token);
}
$this->serverurl->param('wsdl', 1);
//zend expects 0 based array with numeric indexes
$params = array_values($params);
$opts = array(
'http' => array(
'user_agent' => 'Moodle SOAP Client'
)
);
$context = stream_context_create($opts);
$this->options['stream_context'] = $context;
$this->options['cache_wsdl'] = WSDL_CACHE_NONE;
//traditional Zend soap client call (integrating the token into the URL)
$result = $this->__call($functionname, $params);
$client = new SoapClient($this->serverurl->out(false), $this->options);
return $result;
return $client->__soapCall($functionname, $params);
}
}
\ No newline at end of file
}
This diff is collapsed.
This diff is collapsed.
......@@ -25,6 +25,6 @@
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2015111600; // The current plugin version (Date: YYYYMMDDXX)
$plugin->version = 2016020900.00; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2015111000; // Requires this Moodle version
$plugin->component = 'webservice_soap'; // Full name of the plugin (used for diagnostics)
This diff is collapsed.
......@@ -10,8 +10,11 @@ This information is intended for authors of webservices, not people writing webs
"[methodname]" does not exist') are no longer used which may display a different error message depending
on the string returned by the getMessage() method of the thrown exception.
* The xmlrpc server is no longer enabled when the Mobile service is activated.
* Support for the AMF protocol has been dropped completely.
* Zend_SOAP has been dropped. The native PHP SoapClient and SoapServer classes are now being used instead. WSDL is now
generated by the new class webservice_soap_wsdl. For fault strings, a different error message might be shown depending
on the string returned by the getMessage() method of the thrown exception.
* With Zend_SOAP dropped, moodle_zend_soap_server is now also deprecated.
=== 3.0 ===
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment