Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-29750

SOAP protocol does not support optional parameters (they are always set to null)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Do
    • Icon: Critical Critical
    • None
    • 2.1.2, 2.2.5, 2.3.2
    • Web Services
    • MOODLE_21_STABLE, MOODLE_22_STABLE, MOODLE_23_STABLE

      Get the ws template (https://github.com/moodlehq/moodle-local_wstemplate), and try to call it with SOAP. I can not find a way to call the web service function with the parameter being set to its default value. In the best case SOAP seems to set to null when no parameter. XMLRPC and REST protocol do set the correct default values.

      My SOAP client code:

      $token = 'caab56bd1c66c2d08c92c22a41ecde64';
      $domainname = 'http://jerome.moodle.local/~jerome/Moodle_wstemplate';
       
      /// FUNCTION NAME
      $functionname = 'local_wstemplate_hello_world';
       
      /// PARAMETERS 
      $welcomemsg = 'Hello, ';
       
      ///// SOAP CALL 
      ini_set("soap.wsdl_cache_enabled", "0"); // no WSDL cache
      $serverurl = $domainname . '/webservice/soap/server.php'. '?wsdl=1&wstoken=' . $token;
      $client = new SoapClient($serverurl);
      try {
          $resp = $client->__soapCall($functionname, array()); //here there is no parameter, I'm expecting the default value.
      } catch (Exception $e) {
          print_r($e);
          exit();
      }
      print_r($resp);

            moodle.com Moodle HQ
            jerome Jérôme Mouneyrac
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.