status = 0; $this->message = "connection established"; unset($waramu); } catch (Exception $e) { $this->status = -1; $this->message = $e->getMessage(); } } public function getXMLStatus() { $dom = new DOMDocument('1.0', 'utf-8'); $node = $dom->createElement('entry'); $entry = $dom->appendChild($node); $node = $dom->createElement('status', $this->status); $entry->appendChild($node); $node = $dom->createElement('message', $this->message); $entry->appendChild($node); return $dom->saveXML(); } public function getJSONStatus() { return json_encode(array( 'status' => $this->status, 'message' => $this->message )); } } $supported_formats = array('xml', 'json'); $format = get_input('format'); if (!in_array($format, $supported_formats)) { $format = 'xml'; } $tester = new WaramuWSTester(); if ($format === 'xml') { header('Content-Type:text/xml'); echo $tester->getXMLStatus(); exit; } else if ($format === 'json') { header('Content-Type:application/json'); echo $tester->getJSONStatus(); exit; } ?>