Index: rest_server.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/rest_server/Attic/rest_server.module,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 rest_server.module
--- rest_server.module	5 Jan 2008 05:39:54 -0000	1.1.2.1
+++ rest_server.module	3 Aug 2008 16:51:01 -0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: rest_server.module,v 1.1.2.1 2008/01/05 05:39:54 robloach Exp $
+// $Id$
 
 /**
  * Implementation of hook_server_info()
@@ -9,51 +9,87 @@
     '#name' => 'REST',
     '#path' => 'rest',
   );
-} // function rest_server_server_info
+} 
 
 /**
  * Implementation of hook_server()
  */
 function rest_server_server() {
-  // Initiate the server and the request
-  if (zend_initialize('Zend_Rest_Server')) {
-    $request = $_REQUEST;
-    $server = new Zend_Rest_Server();
-    
-    // Check for which service we're calling
-    foreach (services_get_all() as $method) {
-      if ($method['#method'] == $request['method']) {
-        $request['method'] = $method['#callback'];
-        $server->addFunction($method['#callback']);
-        
-        // Special use cases for arguments of certain types
-        foreach ($method['#args'] as $argument) {
-          $argname = $argument['#name'];
-          switch ($argument['#type']) {
-            case 'array' :
-              if (empty($request[$argname])) {
-                $request[$argname] = array();
-              }
-              else {
-                $request[$argname] = explode(',', $request[$argname]);
-              }
-              break;
-          }
+  $request = $_REQUEST;
+  $args = array();
+  $rest_request = array();
+  // Check for which service we're calling
+  foreach (services_get_all() as $method) {
+    if ($method['#method'] == $request['method']) {
+      $methodname = $method['#method'];
+      // Special use cases for arguments of certain types
+      foreach ($method['#args'] as $argument) {
+        $argname = $argument['#name'];
+        switch ($argument['#type']) {
+          case 'array' :
+            if (empty($request[$argname])) {
+              $args[] = array();
+            }
+            else {
+              $args[] = explode(',', $request[$argname]);
+            }
+            break;
+          case 'string':
+            if (empty($request[$argname])) {
+              $args[] = '';
+            }
+            else {
+              $args[] = $request[$argname];
+            }
+            break;
+          default:
+            $args[] = $request[$argname];
+            break;
         }
-        
-        // Found method to call, so exit
-        break;
       }
+     $rest_request['method'] = $methodname;
+     $rest_request['args'] = $args;
+      break;
     }
-    try {
-      echo $server->handle($request);
+  }
+  try {
+    $output = rest_server_call_wrapper($rest_request);
+    drupal_set_header('Content-type: text/xml');
+    // Check for returned errors by rest_server_server_error function
+    if(array_key_exists('rest_server_server_error', $output)) {
+      echo convert_to_xml($output['rest_server_server_error'], 'error');
     }
-    catch (Exception $e) {
-      echo $e->getMessage();
+    else {
+      echo convert_to_xml($output, 'success');
     }
+    
   }
-  else {
-    drupal_set_message(t('The <em>REST Server</em> requires proper configuration of the <a href="@url" target="_blank">Zend Framework</a>. Please <a href="@configure">configure it</a> correctly and try again.', array('@url' => 'http://framework.zend.com', '@configure' => url('admin/settings/zend'))), 'error');
-    drupal_goto(variable_get('site_frontpage', 'node'));
+  catch (Exception $e) {
+    $output = $e->getMessage();
+    $arr = array('message' => $output);
+    echo convert_to_xml('Internal error', 'error');
   }
-} // function rest_server_server
+} 
+
+function rest_server_call_wrapper($request) {
+  $args = $request['args'];
+  $method_name = $request['method'];
+  return services_method_call($method_name, $args);
+}
+
+function convert_to_xml($response, $response_type) {
+  include_once('rest_xml_writer.inc');
+  $writer = new restXmlWriter();
+  $xml_contents = $writer->toXml($response, $response_type);
+  return $xml_contents;
+}
+
+/**
+ * Implementation of hook_server_error
+ *
+ * @param string $message
+ * @return array
+ */
+function rest_server_server_error($message) {
+  return array('rest_server_server_error' => $message);
+}
\ No newline at end of file
Index: rest_server.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/rest_server/Attic/rest_server.info,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 rest_server.info
--- rest_server.info	5 Jan 2008 05:39:54 -0000	1.1.2.1
+++ rest_server.info	3 Aug 2008 16:51:01 -0000
@@ -2,4 +2,4 @@
 name = REST Server
 description = Provides a REST server.
 package = "Services - servers"
-dependancies = zend services
+dependancies = services
Index: .project
===================================================================
RCS file: .project
diff -N .project
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ .project	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>REST Server</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+	</buildSpec>
+	<natures>
+	</natures>
+</projectDescription>
