Extending local_wstemplate_hello_world

Extending local_wstemplate_hello_world

by Charan Sri -
Number of replies: 0

Hello All,

I have installed local_wstemplate_hello_world webservice and tested it. It works fine, Now I want to extend this service, like I want to add some additional methods in this externallib.php file and want to call those methods using webservice.

I have added three methods as below in externallib.php file:

1) function userCredit_parameters()

2) function userCredit()

3) function userCredit_returns()


In Services.php file. I have added code as below:

$services = array(

        'My service' => array(

                'functions' => array ('local_wstemplate_hello_world', 'local_wstemplate_userCredit'),

                'restrictedusers' => 0,

                'enabled'=>1,

        )

);


$functions = array(

        'local_wstemplate_hello_world' => array(

                'classname'   => 'local_wstemplate_external',

                'methodname'  => 'hello_world',

                'classpath'   => 'local/wstemplate/externallib.php',

                'description' => 'Return Hello World FIRSTNAME. Can change the text (Hello World) sending a new text as parameter',

                'type'        => 'read',

        ),

'local_wstemplate_userCredit' => array(

                'classname'   => 'local_wstemplate_external',

                'methodname'  => 'userCredit',

                'classpath'   => 'local/wstemplate/externallib.php',

                'description' => 'Return Hello World FIRSTNAME. Can change the text (Hello World) sending a new text as parameter',

                'type'        => 'read',

        )

);


Now, When I want to call the method 'userCredit()' from a webservice using wsfunction = local_wstemplate_userCredit.


It is showing error as follows:

stdClass Object
(
    [exception] => dml_missing_record_exception
    [errorcode] => invalidrecord
    [message] => Can not find data record in database table external_functions.
    [debuginfo] => SELECT * FROM {external_functions} WHERE name = ?
[array (
  0 => 'local_wstemplate_userCredit',
)]
)

Please help me on how to fix this issue?

Thanks in Advance

Regards

Sricharan



Average of ratings: -