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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Critical
    • Resolution: Unresolved
    • Affects Version/s: 2.1.2, 2.2.5, 2.3.2
    • Fix Version/s: STABLE backlog
    • Component/s: Web Services
    • Labels:
    • Affected Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE, MOODLE_23_STABLE

      Description

      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);

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              moodle.com moodle.com
              Reporter:
              jerome Jérôme Mouneyrac
              Participants:
              Component watchers:
              Juan Leyva, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated: