We are trying to use the web service stuff, and have got a long way, and it seems very nice and easy to work with, but we have hit a problem right at the end.
We have our function in local/coursefeaturesservice/externallib.php.
The metadata about the function is:
public static function get_user_course_features_parameters() {
return new external_function_parameters(
array(
'username' => new external_value(PARAM_ALPHANUM, 'user name'),
'courseshortname' => new external_value(PARAM_MULTILANG, 'course short name')
)
);
}
public static function get_user_course_features_returns() {
return new external_single_structure(
array(
'status' => new external_value(PARAM_TEXT, 'status, OK or ERROR'),
'userid' => new external_value(PARAM_INT, 'user id'),
'courseid' => new external_value(PARAM_INT, 'course id'),
'gradebook' => new external_value(PARAM_TEXT, 'gardebook, visible or hidden')
)
);
}
I have set up a service and a used and a token and everything. (Plugins / Web services / Overview is great!) I can even run the service using the built-in test client.
However, when I generate the WSDL (by going to http://.../webservice/soap/server.php?wsdl=1&wstoken=... - and can I say it took my hours to work out that that was the right URL - I had better add a note to the docs) then the WSDL that is generated seems to be invalid. It generates WDSL including this fragment:
<message name="local_get_user_course_featuresOut">
<part name="return" type="xsd:struct"/>
</message>
and I am getting the error
The part 'return' has an invalid value 'struct' defined for its type. Type declarations must refer to valid values defined in a schema.
on teh part name="return" line. (I get that by opening the WSDL with Eclipse's WSDL editor.)
Is this something we are doing wrong, or is it a bug with the Moodle web-service system?
Thanks.