webservice template not working

webservice template not working

by Conn Warwicker -
Number of replies: 3
Picture of Core developers Picture of Plugin developers

Hi,

I'm using this webservice template to see how to use the webservices in Moodle:

https://github.com/moodlehq/moodle-local_wstemplate

I've installed the local plugin, made sure evrything is enabled, generated a token for the service, updated the client.php with the token and the correct URL, but I just get this error:


Array
(
    [faultCode] => 29039061
    [faultString] => Invalid parameter value detected | DEBUG INFO: Unexpected keys (<?xml_version) detected in parameter array. | ERRORCODE: invalidparameter
)



Does anyone know if there is anything missing from that template? Or have I missed a step somewhere?

This is for Moodle 3.1

Cheers.

---------

Had a deeper look and it is sending this rawpostdata:

<?xml version="1.0" encoding="iso-8859-1"?>
<methodCall>
<methodName>local_wstemplate_hello_world</methodName>
<params>
 <param>
  <value>
   <string>Hello, </string>
  </value>
 </param>
</params>
</methodCall>

But then this method call:
        $decodedparams = xmlrpc_decode_request($rawpostdata, $methodname);

Is leaving the $methodname as NULL and not changing it



Average of ratings: -
In reply to Conn Warwicker

Re: webservice template not working

by Sebastian Schedlbauer -

I had exactly the same issue. The client.php did not work, as far as i remember it was because the client was transmitting additional parameters which did not pass the validator of webservice

I sent raw requests using simple curl calls, see example on gist. Its without parameter, but would also work with function parameters

https://gist.github.com/Sebastiansch/ce07f400b59fdc5a13f95319688a0bb4


Nevertheless, for testing using REST API would be easier

Call would be something linke: http://moodle.localhost/webservice/rest/server.php?wstoken=xxx&wsfunction=local_wstemplate_hello_world&whateverparameteryouneed=xxx


In reply to Sebastian Schedlbauer

Re: webservice template not working

by Conn Warwicker -
Picture of Core developers Picture of Plugin developers

Having issues now with getting it to work on a live server.

When I was calling the webservice on my localhost it was fine, but now I'm trying to call the one on the live server, i'm getting apache error 403 forbidden.

Anyone know what apache config I need to change to let it work?


Edit: never mind, forgot to enable webservices on the server