/**
  * Call a URL directly, without it being mapped to a configured web method.
  *
  * This differs from the above in that the caller already knows what
  * URL is trying to be called, so we can bypass the business of mapping
  * arguments all over the place.
  *
  * We still maintain the globalParams for this client though
  *
  * @param $url
  * 			The URL to call
  * @param $args
  * 			Parameters to be passed on the call
  * @return mixed
  */
 public function callUrl($url, $args = array(), $returnType = 'raw', $requestType = 'GET', $cache = 300, $enctype = Zend_Http_Client::ENC_URLENCODED)
 {
     $body = null;
     // use the method params to try caching the results
     // need to add in the baseUrl we're connecting to, and any global params
     // because the cache might be connecting via different users, and the
     // different users will have different sessions. This might need to be
     // tweaked to handle separate user logins at a later point in time
     $cacheKey = md5($url . $requestType . var_export($args, true) . var_export($this->globalParams, true));
     $requestType = isset($methodDetails['method']) ? $methodDetails['method'] : 'GET';
     if (mb_strtolower($requestType) == 'get' && $cache) {
         $body = CacheService::inst()->get($cacheKey);
     }
     if (!$body) {
         $uri = $url;
         $client = $this->getClient($uri);
         $client->setMethod($requestType);
         // set the encoding type
         $client->setEncType($enctype);
         $paramMethod = 'setParameter' . $requestType;
         // make sure to add the alfTicket parameter
         if ($this->globalParams) {
             foreach ($this->globalParams as $key => $value) {
                 $client->{$paramMethod}($key, $value);
             }
         }
         foreach ($args as $index => $pname) {
             $client->{$paramMethod}($index, $pname);
         }
         // request away
         $response = $client->request();
         if ($response->isSuccessful()) {
             $body = $response->getBody();
             if ($cache) {
                 CacheService::inst()->store($cacheKey, $body, $cache);
             }
         } else {
             if ($response->getStatus() == 500) {
                 error_log("Failure: " . $response->getBody());
                 error_log(var_export($client, true));
             }
             throw new FailedRequestException("Failed executing {$url}: " . $response->getMessage() . " for request to {$uri} (" . $client->getUri(true) . ')', $response->getBody());
         }
     }
     // see what we need to do with it
     if (isset($this->returnHandlers[$returnType])) {
         $handler = $this->returnHandlers[$returnType];
         return $handler->handleReturn($body);
     } else {
         return $body;
     }
 }
    /**
     * Gets an object based on its ID
     * 
     * @param String $id
     * @return array
     */
    public function getObject($id)
    {
        $cacheKey = md5($this->url . '|getObject|' . $id . '|' . $this->username);
        $data = CacheService::inst()->get($cacheKey);
        if (!$data) {
            $id = $this->getCompoundId($id);
            if (!$id->id) {
                // just the list
                $lists = $this->getLists();
                return isset($lists[$id->listId]) ? $lists[$id->listId] : null;
            }
            $xml = <<<XML
\t\t\t<Query>
\t\t\t   <Where>
\t\t\t      <Eq>
\t\t\t         <FieldRef Name="ID" />
\t\t\t         <Value Type="Counter">{$id->id}</Value>
\t\t\t      </Eq>
\t\t\t   </Where>
\t\t\t</Query>
XML;
            $searchQueryArgs = array('listName' => $id->listId, 'queryOptions' => array(self::SEARCH_QUERY_OPTIONS), 'query' => array($xml));
            $result = $this->getClient()->call('GetListItems', $searchQueryArgs);
            // This result SHOULD be of the form
            /*Array
            		(
            		    [GetListItemsResult] => Array
            		        (
            		            [listitems] => Array
            		                (
            		                    [data] => Array
            		                        (
            		                            [row] => Array*/
            $obj = null;
            if (isset($result['GetListItemsResult']['listitems']['data']['row'])) {
                $obj = $this->sanitiseObject($result['GetListItemsResult']['listitems']['data']['row'], $id->listId);
                // set the compound ID
            }
            CacheService::inst()->store($cacheKey, $obj);
            return $obj;
        }
        return $data;
    }