protected function handle() {
        if ($this->wsdlmode) {
            // Prepare the response.
            $this->response = $this->wsdl->to_xml();

            // Send the results back in correct format.
            $this->send_response();
        } else {
            $wsdlurl = clone($this->serverurl);
            $wsdlurl->param('wsdl', 1);

            $options = array(
                'uri' => $this->serverurl->out(false)
            );
            // Initialise the SOAP server.
            $this->soapserver = new SoapServer($wsdlurl->out(false), $options);
            if (!empty($this->serviceclass)) {
                $this->soapserver->setClass($this->serviceclass);
                // Get all the methods for the generated service class then register to the SOAP server.
                $functions = get_class_methods($this->serviceclass);
                $this->soapserver->addFunction($functions);
            }

            // Get soap request from raw POST data.
            $soaprequest = file_get_contents('php://input');
            // Handle the request.
            try {
                $this->soapserver->handle($soaprequest);
            } catch (Exception $e) {
                $this->fault($e);
            }
        }
    }