/** * Handle web service request * * @param array|bool $request The request (Really only used for testing) * @param boolean $return Return the response or not (Really only used for testing) * @return void|string */ public function handle($request = false, $return = false) { try { // Set the request to our server's request if (is_array($request)) { $this->get_request()->setParams($request); } // Security checks $this->security(); // Server setup $this->server->setClass($this->serviceclass, '', array($this, $this->get_response())); $this->server->returnResponse(true); // Output buffer when not testing (ensures clean response) if (!PHPUNIT_TEST) { ob_start(); } // Run the server $response = $this->server->handle($request); // Close output buffer if needed if (!PHPUNIT_TEST) { ob_end_clean(); } // Allow response class to look at the response $response = $this->get_response()->post_handle($response); } catch (Exception $e) { $response = $this->fault($e->getMessage()); } if ($return) { return $response; } $this->send_headers(); echo $response; die; }