How to write a service module for Drupal 7 and Services 3.x?
In addition to the link mentioned, here's some code from a module I wrote that uses webservices. Under "structure" the service should be enabled and an endpoint defined. You also set the allowed return types there. 

So if you define 'api' as endpoint and want a json array, you would do a request like yoursite.com/api/servicename/arg1/arg2.json. You define the service name in  hook_services_resources.

&lt;?php

// $Id$
/* * **********************************************************************************************
 * @file
 * Based on the RESTful API shell module http://drupal.org/node/1034540
 */

/* * *************************************************************************************************
 * Include necessary files
 */
require_once (drupal_get_path('module', 'graph_data_api') . '/model/highchart_graph.php');

/* * *************************************************************************************************
 * Implementation of hook_help().
 * @see http://api.drupal.org/api/function/hook_help/6
 */

function graph_data_api_help($path, $arg) {
  $msg = t('&lt;p&gt;Provides a API for graph data for use with Highcharts.&lt;/p&gt;');
  switch ($path) {
    case 'admin/help#graph_data_api':
      return $msg;
    case 'admin/modules#description':
      return $msg;
  }
}

/* * *************************************************************************************************
 * Implementation of hook_disable()
 * @see http://api.drupal.org/api/function/hook_disable/6
 */

function graph_data_api_disable() {
  cache_clear_all('services:methods', 'cache');
  //eco_debug( '*** graph_data_api_disable() called!' );
}

/* * *************************************************************************************************
 * Implementation of hook_enable()
 * @see http://api.drupal.org/api/function/hook_enable/6
 */

function graph_data_api_enable() {
  cache_clear_all('services:methods', 'cache');
  //eco_debug( '*** graph_data_api_enable() called!' );
}

/* * *************************************************************************************************
 * Implementation of hook_perm().
 * @see http://api.drupal.org/api/function/hook_perm/6
 */

function graph_data_api_permission() {
  return array(
      'request graph data' =&gt; array(
          'title' =&gt; t('Request graph data'),
          'description' =&gt; t('Allows user to use the graph api for Highchart graphs'),
      ),
  );
}

/* * *************************************************************************************************
 * Access callback 
 * For now only view/retrieve is implemented and if the user is logged in, he gets access
 */

function _graph_data_api_graphdata_access($op) {
  global $user;
  $access = FALSE;

  switch ($op) {
    case 'view':
      if ($user-&gt;uid) {
        $access = TRUE;
      }
      break;
  }

  return $access;
}

/* * *************************************************************************************************
 * Implementation of hook_services_resources().
 * For now only retrieve with a GET request is implemented
 */

function graph_data_api_services_resources() {
  return array(
      'graphdata' =&gt; array(
          'retrieve' =&gt; array('help' =&gt; 'Retrieves graphdata',
              'callback' =&gt; '_graph_data_api_graphdata_retrieve',
              'access callback' =&gt; '_graph_data_api_graphdata_access',
              'access arguments' =&gt; array('view'),
              'access arguments append' =&gt; FALSE,
              'args' =&gt; array(
                  array('name' =&gt; 'parameters',
                      'type' =&gt; 'string',
                      'description' =&gt; 'The parameters that define requested data',
                      'source' =&gt; array('path' =&gt; '0'), // first argument in the url 
                      'optional' =&gt; FALSE,
                  ),
              ),
          ),
      ),
  );
}

/* * *************************************************************************************************
 * Callback for the retrieve resource
 */

function _graph_data_api_graphdata_retrieve($arg) {

  $data = 'hello world';
  return $data;
}