Posted by bsenftner on August 28, 2009 at 11:13pm
Using Drupal 6.13, Services 6x-2x-dev
I am working towards implementing a web API to expose some computational services of my company. Starting out with a basic module that depends upon the Services.module, I am seeing these unexpected behaviors:
- only the first service function appears, none of the others
- the '#help' text for my service never appears
- if I deactivate my module, I still see it listed in the Services Browser (admin/build/services)
Here's the code that I have, which is pretty little at this point. I really only care about the first issue at this point (I'll figure out the rest as I continue development)
What am I doing wrong such that only the first function is ever recognized?
function myAPI_service()
{
return array(
array(
'#method' => 'myAPI.init',
'#callback' => 'myAPI_init',
'#return' => 'string',
'#help' => t('Initialize, or verify initialization, of the myAPI subsystem'), // where are you??? never appears!
),
// behaves as if the below array does not exist
array(
'#method' => 'myAPI.test',
'#callback' => 'myAPI_test',
'#return' => 'string',
'#help' => t('test routine for understanding how the Services module works'),
),
);
}
// this one works fine:
function myAPI_init()
{
return 'okay';
}
// never called, due to something missing in myAPI_service() array return value above?
function myAPI_test()
{
return 'test returns okay';
}
Comments
answering my own question
after examining some of the other example services within services.module, I noticed the usage of hook_disable() and hook_enable(), and added them to my module:
function myAPI_disable() {cache_clear_all('services:methods', 'cache');
}
function myAPI_enable() {
cache_clear_all('services:methods', 'cache');
}
Once these were in place, all the above issues disappeared. Somewhere there ought to be a note within the Services documentation pointing out how important it is to use these hooks.
This is now mentioned in the
This is now mentioned in the documentation: http://drupal.org/node/118126