Creating your own Webservices with drupal 6

1. Download services module from 2. Unzip the service module directory and copy inside sites/all/modules directory 3. Now Enable the module, for that you need to open web browser => navigate to your drupal website => Goto Site building => Modules => List => Enable services and XMLRPC Server => save configuration 4. Goto Site Building => Services => Setings => Uncheck Use keys & Use sessid boxes => save configuration All settings are done. Now time to write your own services. 1. Create a directory for your service inside sites/all/modules directory, say myservices. 2. Here you need to create 3 files: i) ii) myservices.module iii) 3. Open and write following lines ; $Id:,v 1.5 2009/01/20 18:20:21 sheetal Exp $ name = My services description = Expose basic services. package = Services - service version = VERSION dependencies[] = services core = 6.x ; Information added by packaging script on 2008-12-11 version = "6.8" project = "drupal" datestamp = "1229018427" 4. Now open myservices.module You should know about drupal module development for writing the webservices. For example, create a function myservices_service(). function myservices_service(){ return array( array( '#method' => 'myservices.test', '#callback' => 'myservices_test', '#file' => array('file' => 'inc', 'module' => 'myservices'), '#args' => array( array( '#name' => 'your_name', '#type' => 'string', '#description' => t('A valid name.'), ) ) }; 5. Now open This file will contain the actual code function myservices_test($name){ $response = "Welcome " . $name; //your code will come here return $response; } 6. Everything is completed. Test your webservice by going to Site Building => Services => Browse Here you will see the list of services which you have created, i.e. myservices.test You will also see the XMLRPC server. 7. Now click on the services, you will see the output.


Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>

More information about formatting options