예제 #1
0
 /**
  * Generate
  *
  * @param string $service_description Service Description
  *
  * @return null
  */
 public function generate($service_description)
 {
     SCA::$logger->log("Entering");
     try {
         $smd_str = SCA_GenerateSmd::generateSmd($service_description);
         SCA::sendHttpHeader('Content-type: text/plain');
         echo $smd_str;
     } catch (SCA_RuntimeException $se) {
         echo $se->exceptionString() . "\n";
     } catch (SDO_DAS_XML_FileException $e) {
         throw new SCA_RuntimeException("{$e->getMessage()} in {$e->getFile()}");
     }
     return;
 }
예제 #2
0
 /**
  * handle incomming JSON RPC requests
  */
 public function handle()
 {
     $request = self::getRequest();
     // get the jsonrpc element from the request
     $method = $request->method;
     $params = $request->params;
     $id = $request->id;
     // create an object that holds the params
     // - numbers / strings / booleans -  remain as PHP objects
     // - objects - become SDOs, we obtain the type of each param from annotations
     // - arrays are invalid at the top level - params must be primitive or SDO
     $new_params_array = array();
     //get the list of parameter types
     $parameter_descriptions = $this->service_wrapper->getParametersForMethod($method);
     foreach ($params as $param_name => $param_value) {
         $param_description = $parameter_descriptions[$param_name];
         $param_type = gettype($param_value);
         /* some debug
            ob_start();
            $debug =  " ParamName: "  . $param_name . " ParamValue: " . $param_value . " ParamType: "  . $param_type . "\n";
            echo $debug;
            print_r($param_description);
            $debug = ob_get_contents();
            ob_end_clean();
            file_put_contents("json_messages.txt",
            $debug,
            FILE_APPEND);
            */
         if ($param_type == "object") {
             if (array_key_exists('objectType', $param_description) && array_key_exists('namespace', $param_description)) {
                 $new_params_array[] = $this->service_wrapper->getJsonDas()->decodeFromPHPObject($param_value, $param_description["objectType"], $param_description["namespace"]);
             } else {
                 throw new SCA_RuntimeException("Method {$method} parameter {$param_name} appears " . "to be and SDO but doesn't have a suitable " . "@param description element as the type and " . "namespace are not both defined");
             }
         } else {
             if ($param_type == "array") {
                 throw new SCA_RuntimeException("Parameter {$param_name} of type array found as " . "a top level parameter of incoming message {$rawHTTPContents} " . " message parameters must be either primitives or SDOs");
             } else {
                 $new_params_array[] = $param_value;
             }
         }
     }
     $response = "{\"id\":" . $id . ",";
     /*
     try {
     $call_response = $this->service_wrapper->__call($method, $new_params_array);
     $response      = $response . "\"result\":" . $call_response;
     }
     catch ( Exception $ex) {
     $response     = $response . "\"error\":" . json_encode($ex->getMessage());
     }
     */
     $call_response = "null";
     $error_response = "null";
     try {
         $call_response = $this->service_wrapper->__call($method, $new_params_array);
     } catch (Exception $ex) {
         $error_response = json_encode($ex->getMessage());
     }
     $response = $response . "\"result\":" . $call_response;
     $response = $response . ",\"error\":" . $error_response;
     $response = $response . ",\"version\":\"1.0\"}";
     // some debugging
     //            file_put_contents("json_messages.txt",
     //            "Response at JSONRPC server = " . $response . "\n",
     //            FILE_APPEND);
     SCA::$logger->log("Response at JSONRPC server = " . $response);
     SCA::sendHttpHeader('Content-type: application/json-rpc');
     echo $response;
     return;
 }
예제 #3
0
파일: Server.php 프로젝트: psagi/sdo
 /**
  * Handle
  *
  * @return mixed
  */
 public function handle()
 {
     SCA::$logger->log("Entering");
     try {
         // get the name of the method to call from the URL
         $method = $_SERVER['PATH_INFO'];
         // strip the forward slash from the beginning of this string
         $length_of_method = strlen($method);
         $method = substr($method, 1, $length_of_method);
         SCA::$logger->log("The method is {$method}");
         //Get the service description for the class.
         $param_description = $this->service_wrapper->getParametersForMethod($method);
         $verb = $_SERVER['REQUEST_METHOD'];
         if ($verb === 'POST') {
             SCA::$logger->log("Processing POST");
             // decide what the input type is and pull out the
             // parameters accordingly
             $params_array = null;
             SCA::$logger->log("Content type = " . $_SERVER['CONTENT_TYPE']);
             if (stripos($_SERVER['CONTENT_TYPE'], 'x-www-form-urlencoded')) {
                 // form input
                 SCA::$logger->log("Form parameters found");
                 $params_array = $this->fromRequest($_POST, $param_description);
             } else {
                 if (stripos($_SERVER['CONTENT_TYPE'], "xml")) {
                     //XML input
                     SCA::$logger->log("XML Input found");
                     // Get the request body
                     $rawHTTPContents = file_get_contents("php://input");
                     SCA::$logger->log("raw http contents = " . $rawHTTPContents);
                     $params_array = $this->fromXML($rawHTTPContents);
                 } else {
                     // if no form params or xml provided we assume
                     // no parameters are required
                     SCA::$logger->log("No parameters found");
                 }
             }
             $call_response = null;
             $call_response = $this->service_wrapper->__call($method, $params_array);
         } else {
             if ($verb === 'GET') {
                 SCA::$logger->log("Processing GET");
                 $params_array = $this->fromRequest($_GET, $param_description);
                 $call_response = null;
                 $call_response = $this->service_wrapper->__call($method, $params_array);
             }
         }
         SCA::sendHttpHeader("HTTP/1.1 200");
         if ($call_response !== null) {
             if ($call_response instanceof SDO_DataObjectImpl) {
                 //if the thing received is SDO convert it to XML
                 SCA::sendHttpHeader("Content-Type: text/xml");
                 echo $this->toXml($call_response);
             } else {
                 SCA::sendHttpHeader("Content-Type: text/plain");
                 echo $call_response;
             }
         }
     } catch (SCA_ServiceUnavailableException $ex) {
         SCA::$logger->log("caught SCA_ServiceUnavailableException when calling method {$method}");
         //TODO: log more info, class the method was called on, msg.
         SCA::sendHttpHeader("HTTP/1.1 503");
     } catch (SCA_ConflictException $ex) {
         SCA::$logger->log("caught SCA_ConflictException when calling method {$method}");
         //TODO: log more info, class the method was called on, msg.
         SCA::sendHttpHeader("HTTP/1.1 409");
     } catch (SCA_AuthenticationException $ex) {
         SCA::$logger->log("caught SCA_AuthenticationException when calling method {$method}");
         //TODO: log more info, class the method was called on, msg.
         SCA::sendHttpHeader("HTTP/1.1 407");
     } catch (SCA_BadRequestException $ex) {
         SCA::$logger->log("caught SCA_BadRequestException when calling method {$method}");
         //TODO: log more info, class the method was called on, msg.
         header("HTTP/1.1 400");
     } catch (SCA_InternalServerErrorException $ex) {
         SCA::$logger->log("caught SCA_InternalServerErrorException when calling method {$method}");
         //TODO: log more info, class the method was called on, msg.
         SCA::sendHttpHeader("HTTP/1.1 500");
     } catch (SCA_UnauthorizedException $ex) {
         SCA::$logger->log("caught SCA_UnauthorizedException when calling method {$method}");
         //TODO: log more info, class the method was called on, msg.
         SCA::sendHttpHeader("HTTP/1.1 401");
     } catch (SCA_MethodNotAllowedException $ex) {
         //catch problem finding the method encountered by the service wrapper.
         SCA::$logger->log("caught SCA_MethodNotAllowedException when calling method {$method}");
         //TODO: log more info, class the method was called on, msg.
         SCA::sendHttpHeader("HTTP/1.1 405");
     } catch (SCA_RuntimeException $ex) {
         SCA::$logger->log("Caught SCA_RuntimeException in restrpc server: " . $ex->getMessage() . "\n");
         //TODO: output exceptions correctly.
         SCA::sendHttpHeader("HTTP/1.1 500");
     } catch (Exception $ex) {
         $call_response['error'] = $ex->getMessage();
         SCA::$logger->log("Found exception in restrpc server: " . $ex->getMessage() . "\n");
         //TODO sort out how we want to do this:
         //at the moment, only send back the message in the body
         //if the http code spec says a body can be present.
         SCA::sendHttpHeader("HTTP/1.1 500");
     }
     return;
 }
예제 #4
0
 /**
  * Handle
  *
  * @return mixed
  */
 public function handle()
 {
     SCA::$logger->log("Entering");
     $actions = array('POST' => array('create', 1), 'GET' => array('retrieve', 1), 'PUT' => array('update', 2), 'DELETE' => array('delete', 1));
     if (array_key_exists($_SERVER['REQUEST_METHOD'], $actions)) {
         $methodWithNumberOfParams = $actions[$_SERVER['REQUEST_METHOD']];
         $method = $methodWithNumberOfParams[0];
         SCA::$logger->log("Request received: {$method}");
     } else {
         //TODO find out correct response
         SCA::sendHttpHeader("HTTP/1.1 404 Not Found");
         echo $_SERVER['REQUEST_METHOD'] . " Not Supported.";
         return;
     }
     //*handle situations where we have the id in the url.*/
     /**
     These look like the variables to use:
        [REQUEST_URI] => /Samples/Atom/Contact.php/12
        [SCRIPT_NAME] => /Samples/Atom/Contact.php
        [PATH_INFO] => /12
     */
     /*
      * Note, if the PATH_INFO is not working, and you are using Apache 2.0,
      * check the AcceptPathInfo directive for php files.
      * See http://httpd.apache.org/docs/2.0/mod/core.html#acceptpathinfo
      */
     //Set $id - works for non-selector style, but not for selector style.
     if (isset($_SERVER['PATH_INFO'])) {
         $param = $_SERVER['PATH_INFO'];
         //test different length of param
         //$param = "/344656";
         //TODO: is there a case where there will not be a slash in [PATH_INFO]?
         //strip slash
         $lengthOfParam = strlen($param);
         $id = substr($param, 1, $lengthOfParam);
         SCA::$logger->log("Resource id: {$id}");
     } else {
         $id = null;
     }
     //TODO should also check at this stage whether we have invalid combos such as PUT with null $id
     // POST
     // Get the request body
     $rawHTTPContents = file_get_contents($this->input_stream);
     SCA::$logger->log("raw http contents = " . $rawHTTPContents);
     try {
         //Get (and check) the service description for the class.
         $param_description = $this->service_wrapper->getParametersForMethod($method);
         //NOTE: we always give the component an sdo, but handle sdo or xml back from it.
         if ($method === 'create') {
             SCA::$logger->log("The method is create()");
             $sdo = $this->fromXml($rawHTTPContents);
             //should now have an atom format sdo
             if (!$sdo instanceof SDO_DataObjectImpl) {
                 SCA::sendHttpHeader("HTTP/1.1 400 Bad Request");
                 echo "Request did not contain valid atom format xml";
             }
             SCA::$logger->log("Created an sdo from the xml input: {$sdo}");
             $params_array = array($sdo);
             $call_response = null;
             $call_response = $this->service_wrapper->__call($method, $params_array);
             SCA::$logger->log("call response: {$call_response}");
             if ($call_response !== null) {
                 if (!$call_response instanceof SDO_DataObjectImpl) {
                     //if the thing received is xml...
                     //convert it to sdo
                     $call_response = $this->fromXml($call_response);
                 }
                 SCA::$logger->log("Call Response Structure: " . print_r($call_response, true));
                 //TODO: consider this - might some atom feeds still try to provide the link as the value of the link element rather than as an href attribute?
                 //$link = $call_response->link[0]->value;
                 //TODO: consider this - there might be a whole bunch of link elements, could there be more than one that has no 'rel' attribute?
                 //if this is not found, $rel will be null
                 //$rel = $call_response->link[1]->rel;
                 //but
                 //can't do this because $rel won't just be null if its not there.
                 //$rel = $link->rel;
                 //if ($rel === null) {
                 $location = null;
                 foreach ($call_response->link as $link) {
                     SCA::$logger->log("Found link element: {$link}");
                     if (isset($link->rel) === false) {
                         $location = $link->href;
                     }
                 }
                 //if the location is still null, then there might be a number of reasons why.
                 //Handle the case where the reason is that all the link elements have a rel element. Use the href of first link element by default. TODO: this is not enough: we need a way of detecting the BEST 'rel' to use.
                 if ($location === null) {
                     SCA::$logger->log("Could not find a link element that did not have a rel attribute so using the first href provided as the resource location.");
                     //if there is no href then $location will still be null.
                     $location = $call_response->link[0]->href;
                 }
                 SCA::$logger->log("Location of resource: {$location}");
                 //convert response to xml to send back
                 $response = $this->toXml($call_response);
                 //Is the 'false' param required?
                 //It is for sending headers of the same type and
                 //these are different types?
                 SCA::sendHttpHeader("HTTP/1.1 201 Created", false, 201);
                 //Get out the link field and use it instead of the id.
                 //$link = $call_response->link[0]->value;
                 SCA::sendHttpHeader("Location:{$location}");
                 SCA::sendHttpHeader("Content-Type: application/atom+xml");
                 echo $response;
             } else {
                 //TODO sort out what we will flow back:
                 //at the moment, only send back the message in the body
                 //if the http code spec says a body can be present.
                 //if the call response is null, then the create() method on the
                 //component did not return the body of the entry to be returned to
                 //the user. This would mean that they have not conformed to the spec
                 //but will it always mean that the create failed?
                 SCA::$logger->log("According to the Atompub Spec, expected create() on the component to return a copy of the successfully created resource but it has returned nothing.");
                 SCA::sendHttpHeader("HTTP/1.1 500 Internal Server Error");
                 //echo "Failed to create resource. \n";
             }
         } else {
             if ($method === 'retrieve') {
                 SCA::$logger->log("The method is retrieve()");
                 $call_response = null;
                 if ($id === null) {
                     $method = 'enumerate';
                 }
                 SCA::$logger->log("Calling {$method} on the Atom service wrapper");
                 //requests come in with the default syntax "http://server/component.php/id"
                 $call_response = $this->service_wrapper->__call($method, $id);
                 SCA::$logger->log("Response from calling the method {$method} is: {$call_response}");
                 if ($call_response !== null) {
                     if ($call_response instanceof SDO_DataObjectImpl) {
                         //if the thing received is an sdo...
                         //convert it to xml
                         $response_sdo = $this->toXml($call_response);
                     } else {
                         $response_sdo = $call_response;
                     }
                     SCA::sendHttpHeader("HTTP/1.1 200 OK");
                     SCA::sendHttpHeader("Content-Type: application/atom+xml");
                     echo $response_sdo;
                 } else {
                     SCA::$logger->log("Call response was null");
                     SCA::sendHttpHeader("HTTP/1.1 500 Internal Server Error");
                 }
             } else {
                 if ($method === 'update') {
                     SCA::$logger->log("The method is update()");
                     $sdo = $this->fromXml($rawHTTPContents);
                     $params_array = array($id, $sdo);
                     $call_response = null;
                     $call_response = $this->service_wrapper->__call($method, $params_array);
                     if ($call_response === true) {
                         SCA::$logger->log("The update was successful");
                         SCA::sendHttpHeader("HTTP/1.1 200 OK");
                         //NOTE: should not be returning a body.
                     } else {
                         //TODO find out the right response code
                         SCA::sendHttpHeader("HTTP/1.1 500 Internal Server Error");
                     }
                 } else {
                     if ($method === 'delete') {
                         SCA::$logger->log("The method is delete()");
                         $call_response = null;
                         $call_response = $this->service_wrapper->__call($method, $id);
                         if ($call_response === true) {
                             SCA::$logger->log("The delete was successful");
                             SCA::sendHttpHeader("HTTP/1.1 200 OK");
                             //should not be returning a body
                         }
                     }
                 }
             }
         }
     } catch (SCA_ServiceUnavailableException $ex) {
         SCA::$logger->log("caught SCA_ServiceUnavailableException when calling method {$method}");
         //TODO: log more info, class the method was called on, msg.
         SCA::sendHttpHeader("HTTP/1.1 503 Service Unavailable");
     } catch (SCA_ConflictException $ex) {
         SCA::$logger->log("caught SCA_ConflictException when calling method {$method}");
         //TODO: log more info, class the method was called on, msg.
         SCA::sendHttpHeader("HTTP/1.1 409 Conflict");
     } catch (SCA_AuthenticationException $ex) {
         SCA::$logger->log("caught SCA_AuthenticationException when calling method {$method}");
         //TODO: log more info, class the method was called on, msg.
         SCA::sendHttpHeader("HTTP/1.1 407 Proxy Authentication Required");
     } catch (SCA_BadRequestException $ex) {
         SCA::$logger->log("caught SCA_BadRequestException when calling method {$method}");
         //TODO: log more info, class the method was called on, msg.
         SCA::sendHttpHeader("HTTP/1.1 400 Bad Request");
     } catch (SCA_InternalServerErrorException $ex) {
         SCA::$logger->log("caught SCA_InternalServerErrorException when calling method {$method}");
         //TODO: log more info, class the method was called on, msg.
         SCA::sendHttpHeader("HTTP/1.1 500 Internal Server Error");
     } catch (SCA_UnauthorizedException $ex) {
         SCA::$logger->log("caught SCA_UnauthorizedException when calling method {$method}");
         //TODO: log more info, class the method was called on, msg.
         SCA::sendHttpHeader("HTTP/1.1 401 Unauthorized");
     } catch (SCA_NotFoundException $ex) {
         //catch problem finding the requested resource thrown by the component
         SCA::$logger->log("caught SCA_NotFoundException when calling method {$method}");
         //TODO: log more info, class the method was called on, msg.
         SCA::sendHttpHeader("HTTP/1.1 404 Not Found");
     } catch (SCA_MethodNotAllowedException $ex) {
         //catch problem finding the method encountered by the service wrapper.
         SCA::$logger->log("caught SCA_MethodNotAllowedException when calling method {$method}");
         //TODO: log more info, class the method was called on, msg.
         SCA::sendHttpHeader("HTTP/1.1 405 Method Not Allowed");
     } catch (SCA_RuntimeException $ex) {
         SCA::$logger->log("Caught SCA_RuntimeException in AtomServer: " . $ex->getMessage() . "\n");
         //TODO: output exceptions correctly.
         SCA::sendHttpHeader("HTTP/1.1 500 Internal Server Error");
     } catch (Exception $ex) {
         $call_response['error'] = $ex->getMessage();
         SCA::$logger->log("Found exception in AtomServer: " . $ex->getMessage() . "\n");
         //TODO sort out how we want to do this:
         //at the moment, only send back the message in the body
         //if the http code spec says a body can be present.
         SCA::sendHttpHeader("HTTP/1.1 500 Internal Server Error");
     }
     return;
 }
예제 #5
0
 /**
  * Handle
  *
  * @param string $calling_component_filename Filename
  * @param string $service_description        Service description
  *
  * @return mixed
  */
 public function handle($calling_component_filename, $service_description)
 {
     SCA::$logger->log("Entering");
     $class_name = SCA_Helper::guessClassName($calling_component_filename);
     $this->service_wrapper = new SCA_ServiceWrapperAtom($class_name);
     $this->xml_das = $this->service_wrapper->getXmlDas();
     $actions = array('POST' => array('create', 1), 'GET' => array('retrieve', 1), 'PUT' => array('update', 2), 'DELETE' => array('delete', 1));
     if (array_key_exists($_SERVER['REQUEST_METHOD'], $actions)) {
         $methodWithNumberOfParams = $actions[$_SERVER['REQUEST_METHOD']];
         $method = $methodWithNumberOfParams[0];
         SCA::$logger->log("Request received: {$method}");
     } else {
         //TODO find out correct response
         SCA::sendHttpHeader("HTTP/1.1 404 Not Found");
         echo $_SERVER['REQUEST_METHOD'] . " Not Supported.";
         return;
     }
     //*handle situations where we have the id in the url.*/
     /**
     These look like the variables to use:
        [REQUEST_URI] => /Samples/Atom/Contact.php/12
        [SCRIPT_NAME] => /Samples/Atom/Contact.php
        [PATH_INFO] => /12
     */
     /*
      * Note, if the PATH_INFO is not working, and you are using Apache 2.0,
      * check the AcceptPathInfo directive for php files.
      * See http://httpd.apache.org/docs/2.0/mod/core.html#acceptpathinfo
      */
     //Set $id - works for non-selector style, but not for selector style.
     if (isset($_SERVER['PATH_INFO'])) {
         $param = $_SERVER['PATH_INFO'];
         //test different length of param
         //$param = "/344656";
         //TODO: is there a case where there will not be a slash in [PATH_INFO]?
         //strip slash
         $lengthOfParam = strlen($param);
         $id = substr($param, 1, $lengthOfParam);
         SCA::$logger->log("Resource id: {$id}");
     } else {
         $id = null;
     }
     //TODO should also check at this stage whether we have invalid combos such as PUT with null $id
     // POST
     // Get the request body
     $rawHTTPContents = file_get_contents($this->input_stream);
     SCA::$logger->log("raw http contents = " . $rawHTTPContents);
     try {
         //Get (and check) the service description for the class.
         $param_description = $this->service_wrapper->getParametersForMethod($method);
         //NOTE: we always give the component an sdo, but handle sdo or xml back from it.
         if ($method === 'create') {
             SCA::$logger->log("The method is create()");
             $sdo = $this->_fromXml($rawHTTPContents);
             //should now have an atom format sdo
             if (!$sdo instanceof SDO_DataObjectImpl) {
                 SCA::sendHttpHeader("HTTP/1.1 400 Bad Request");
                 echo "Request did not contain valid atom format xml";
             }
             SCA::$logger->log("Created an sdo from the xml input: {$sdo}");
             $params_array = array($sdo);
             $call_response = null;
             $call_response = $this->service_wrapper->__call($method, $params_array);
             if ($call_response !== null) {
                 if (!$call_response instanceof SDO_DataObjectImpl) {
                     //if the thing received is xml...
                     //convert it to sdo
                     $call_response = $this->_fromXml($call_response);
                 }
                 /* only add a trailing slash if there isn't one already */
                 $slash_if_needed = preg_match('/\\/$/', $_SERVER['REQUEST_URI']) ? '' : '/';
                 $port_if_needed = isset($_SERVER['SERVER_PORT']) ? '' : ':' . $_SERVER['SERVER_PORT'];
                 //TODO: Ideally we'd Use http host to get the right scheme part
                 //problem with this is it could pick up the wrong port
                 //for some setups.
                 $created_uri = 'http://' . $_SERVER['SERVER_NAME'] . $port_if_needed . $_SERVER['REQUEST_URI'] . $slash_if_needed . $call_response->id[0]->value;
                 //convert response to xml to send back
                 $response = $this->_toXml($call_response);
                 //Is the 'false' param required?
                 //It is for sending headers of the same type and
                 //these are different types?
                 //SCA::sendHttpHeader("Status: 201 Created", false, 201);
                 SCA::sendHttpHeader("HTTP/1.1 201 Created", false, 201);
                 SCA::sendHttpHeader("Location:{$created_uri}");
                 SCA::sendHttpHeader("Content-Type: application/atom+xml");
                 echo $response;
             } else {
                 //TODO sort out what we will flow back:
                 //at the moment, only send back the message in the body
                 //if the http code spec says a body can be present.
                 //if the call response is null, then the create() method on the
                 //component did not return the body of the entry to be returned to
                 //the user. This would mean that they have not conformed to the spec
                 //but will it always mean that the create failed?
                 SCA::$logger->log("According to the Atompub Spec, expected create() on the component to return a copy of the successfully created resource but it has returned nothing.");
                 SCA::sendHttpHeader("HTTP/1.1 500 Internal Server Error");
                 //echo "Failed to create resource. \n";
             }
         } else {
             if ($method === 'retrieve') {
                 SCA::$logger->log("The method is retrieve()");
                 $call_response = null;
                 if ($id === null) {
                     $method = 'enumerate';
                 }
                 SCA::$logger->log("Calling {$method} on the Atom service wrapper");
                 $call_response = $this->service_wrapper->__call($method, $id);
                 SCA::$logger->log("Response from calling the method {$method} is: {$call_response}");
                 if ($call_response !== null) {
                     if ($call_response instanceof SDO_DataObjectImpl) {
                         //if the thing received is an sdo...
                         //convert it to xml
                         $response_sdo = $this->_toXml($call_response);
                     } else {
                         $response_sdo = $call_response;
                     }
                     SCA::sendHttpHeader("HTTP/1.1 200 OK");
                     SCA::sendHttpHeader("Content-Type: application/atom+xml");
                     echo $response_sdo;
                 } else {
                     SCA::$logger->log("Call response was null");
                     SCA::sendHttpHeader("HTTP/1.1 500 Internal Server Error");
                 }
             } else {
                 if ($method === 'update') {
                     SCA::$logger->log("The method is update()");
                     $sdo = $this->_fromXml($rawHTTPContents);
                     $params_array = array($id, $sdo);
                     $call_response = null;
                     $call_response = $this->service_wrapper->__call($method, $params_array);
                     if ($call_response === true) {
                         SCA::$logger->log("The update was successful");
                         SCA::sendHttpHeader("HTTP/1.1 200 OK");
                         //NOTE: should not be returning a body.
                     } else {
                         //TODO find out the right response code
                         SCA::sendHttpHeader("HTTP/1.1 500 Internal Server Error");
                     }
                 } else {
                     if ($method === 'delete') {
                         SCA::$logger->log("The method is delete()");
                         $call_response = null;
                         $call_response = $this->service_wrapper->__call($method, $id);
                         if ($call_response === true) {
                             SCA::$logger->log("The delete was successful");
                             SCA::sendHttpHeader("HTTP/1.1 200 OK");
                             //should not be returning a body
                         }
                         // TODO - looks a bit odd - what if none of the above tests succeed?
                     }
                 }
             }
         }
     } catch (SCA_ServiceUnavailableException $ex) {
         SCA::$logger->log("caught SCA_ServiceUnavailableException when calling method {$method}");
         //TODO: log more info, class the method was called on, msg.
         SCA::sendHttpHeader("HTTP/1.1 503 Service Unavailable");
     } catch (SCA_ConflictException $ex) {
         SCA::$logger->log("caught SCA_ConflictException when calling method {$method}");
         //TODO: log more info, class the method was called on, msg.
         SCA::sendHttpHeader("HTTP/1.1 409 Conflict");
     } catch (SCA_AuthenticationException $ex) {
         SCA::$logger->log("caught SCA_AuthenticationException when calling method {$method}");
         //TODO: log more info, class the method was called on, msg.
         SCA::sendHttpHeader("HTTP/1.1 407 Proxy Authentication Required");
     } catch (SCA_BadRequestException $ex) {
         SCA::$logger->log("caught SCA_BadRequestException when calling method {$method}");
         //TODO: log more info, class the method was called on, msg.
         SCA::sendHttpHeader("HTTP/1.1 400 Bad Request");
     } catch (SCA_InternalServerErrorException $ex) {
         SCA::$logger->log("caught SCA_InternalServerErrorException when calling method {$method}");
         //TODO: log more info, class the method was called on, msg.
         SCA::sendHttpHeader("HTTP/1.1 500 Internal Server Error");
     } catch (SCA_UnauthorizedException $ex) {
         SCA::$logger->log("caught SCA_UnauthorizedException when calling method {$method}");
         //TODO: log more info, class the method was called on, msg.
         SCA::sendHttpHeader("HTTP/1.1 401 Unauthorized");
     } catch (SCA_NotFoundException $ex) {
         //catch problem finding the requested resource thrown by the component
         SCA::$logger->log("caught SCA_NotFoundException when calling method {$method}");
         //TODO: log more info, class the method was called on, msg.
         SCA::sendHttpHeader("HTTP/1.1 404 Not Found");
     } catch (SCA_MethodNotAllowedException $ex) {
         //catch problem finding the method encountered by the service wrapper.
         SCA::$logger->log("caught SCA_MethodNotAllowedException when calling method {$method}");
         //TODO: log more info, class the method was called on, msg.
         SCA::sendHttpHeader("HTTP/1.1 405 Method Not Allowed");
     } catch (SCA_RuntimeException $ex) {
         SCA::$logger->log("Caught SCA_RuntimeException in AtomServer: " . $ex->getMessage() . "\n");
         //TODO: output exceptions correctly.
         SCA::sendHttpHeader("HTTP/1.1 500 Internal Server Error");
     } catch (Exception $ex) {
         $call_response['error'] = $ex->getMessage();
         SCA::$logger->log("Found exception in AtomServer: " . $ex->getMessage() . "\n");
         //TODO sort out how we want to do this:
         //at the moment, only send back the message in the body
         //if the http code spec says a body can be present.
         SCA::sendHttpHeader("HTTP/1.1 500 Internal Server Error");
     }
     return;
 }